public async Task <ActionResult> Create(ScopeCreateModel model) { if (ModelState.IsValid) { Application.Scopes.Commands.CreateScopeCommand createScopeCommand = model.ToCreateScopeCommand(); createScopeCommand.CreatedBy = User.Identity.Name; createScopeCommand.CreatedOn = DateTime.Now; int result = await Mediator.Send(createScopeCommand); if (result > 0) { return(View("List")); } else { ModelState.AddModelError("", "Thêm Scope thất bại"); } } List <GetAllScopeClaimsDto> scopeClaims = await Mediator.Send(new GetAllScopeClaimsQuery()); model.AvailableClaims = scopeClaims.Select(scopeClaim => new SelectListItem { Value = scopeClaim.Id.ToString(), Text = scopeClaim.Description }).ToList(); return(View(model)); }
public async Task <ActionResult> Create() { ScopeCreateModel model = new ScopeCreateModel(); List <GetAllScopeClaimsDto> scopeClaims = await Mediator.Send(new GetAllScopeClaimsQuery()); model.AvailableClaims = scopeClaims.Select(scopeClaim => new SelectListItem { Value = scopeClaim.Id.ToString(), Text = scopeClaim.Description }).ToList(); return(View(model)); }
public static CreateScopeCommand ToCreateScopeCommand(this ScopeCreateModel model) { return(model.MapTo <ScopeCreateModel, CreateScopeCommand>()); }