using FHT.Agency.Web.Extensions; using FHT.Core.CommonTypes; using FHT.Core.UI.InputModels.Search; using FHT.Management.Interfaces.DependentInterfaces.Services; using FHT.Management.Interfaces.InputModels; using FHT.Management.Interfaces.ViewModels; using FHT.MvcCommon; using System.Collections.Generic; using System.Threading.Tasks; using System.Web.Mvc; namespace FHT.Agency.Web.Areas.Manage.Controllers { [Authorize] public class FaqController : Controller { private readonly IManagementFaqService _faqService; public FaqController(IManagementFaqService faqService) { _faqService = faqService; } /// /// 检索 /// /// /// [HttpGet] public async Task Index(FaqFilterableInputModel args) { ViewBag.Faqs = await _faqService.SearchAsync(args.FaqType, args.Q, args.Limit, args.Offset()); return View(args); } /// /// 创建修改 /// /// /// [HttpGet] public async Task CreateOrUpdate(int? faqId) { var modle = new FaqInputModel(); if (faqId.HasValue) { modle = await _faqService.GetAsync(faqId.Value); } return View(modle); } /// /// 创建修改 /// /// /// [HttpPost] public async Task CreateOrUpdate(FaqInputModel model) { await _faqService.CreateOrUpdateAsync(model); return RedirectToAction(nameof(Index)); } /// /// 删除 /// /// /// [HttpPost] public async Task Delete(int id) { await _faqService.DeleteByIdsAsync(new int[] { id }); return Json(true, JsonRequestBehavior.AllowGet); } /// /// 禁用 /// /// /// [HttpPost] [IsAjaxJsonResult] public JsonResult Frozen(int id) { // await _faqService.ChangeActiveStatusAsync(new int[] { id }, false); return Json(true, JsonRequestBehavior.AllowGet); } /// /// 启用 /// /// /// [HttpPost] [IsAjaxJsonResult] public JsonResult Active(int id) { // await _faqService.ChangeActiveStatusAsync(new int[] { id }, true); return Json(true, JsonRequestBehavior.AllowGet); } [HttpGet] [AllowAnonymous] public async Task Search(FaqType? faqType = null) { List res = await _faqService.GetAllByTypeAsync(faqType); return this.Jsonp(res); } } }