using FHT.Agency.CommonTypes; using FHT.Agency.Web.Filters; using FHT.Core.CommonTypes; using FHT.Core.Queries.ImplementedInterfaces; using FHT.Core.UI.InputModels.Search; using FHT.DDD; using FHT.Management.Interfaces.DependentInterfaces.Services; using FHT.Management.Interfaces.InputModels; using Microsoft.AspNet.Identity; using System.Net; using System.Threading.Tasks; using System.Web.Mvc; namespace FHT.Agency.Web.Areas.Manage.Controllers { [Authorize] public class JoinApplyController : Controller { private readonly IManagementJoinApplyService _managementJoinApplyService; private readonly IRegionQuery _regionQuery; public JoinApplyController(IManagementJoinApplyService managementJoinApplyService, IRegionQuery regionQuery) { _managementJoinApplyService = managementJoinApplyService; _regionQuery = regionQuery; } [HttpGet] [ClaimsAuthorize(FhtUserClaimType.JoinApply)] public async Task Index(FeedBackFilterableInputModel args) { int offset = (args.CurrPage < 2 ? 0 : args.CurrPage - 1) * args.Limit; QueryResult joinApply =await _managementJoinApplyService.SearchAsync(ApplyType.Agency,args.IsDeal, args.Title, args.Limit, offset); ViewBag.JoinApplies = joinApply; return View(args); } [HttpGet] [ClaimsAuthorize(FhtUserClaimType.MemberApply)] public async Task MemberApplies(FeedBackFilterableInputModel args) { int offset = (args.CurrPage < 2 ? 0 : args.CurrPage - 1) * args.Limit; QueryResult joinApply =await _managementJoinApplyService.SearchAsync(ApplyType.Member, args.IsDeal, args.Title, args.Limit, offset); ViewBag.JoinApplies = joinApply; return View(args); } [HttpGet] [ClaimsAuthorize(FhtUserClaimType.JoinApply)] public async Task Detail(long jId) { Management.Interfaces.ViewModels.JoinApplyViewModel model =await _managementJoinApplyService.GetDetailAsync(jId); if (model == null) { return new HttpStatusCodeResult(HttpStatusCode.NotFound); } ViewBag.JoinApply = model; ViewBag.Region = _regionQuery.GetRegionFullPath(model.RegionId); return View(new JoinApplyDealInputModel { JoinId = jId }); } [HttpPost] [ClaimsAuthorize(FhtUserClaimType.JoinApply)] [ValidateAjaxModel] public async Task Deal(JoinApplyDealInputModel model) { int operatorId = User.Identity.GetUserId(); await _managementJoinApplyService.DealAsync(operatorId,model.JoinId); return Json(true,JsonRequestBehavior.AllowGet); } } }