Ejemplo n.º 1
0
        public async Task <ActionResult> Update(int id)
        {
            ScopeUpdateModel model           = new ScopeUpdateModel();
            GetScopeByIdDto  getScopeByIdDto = await Mediator.Send(new GetScopeByIdQuery
            {
                Id = id
            });

            if (getScopeByIdDto != null && getScopeByIdDto.Id > 0)
            {
                model = getScopeByIdDto.ToScopeUpdateModel();
                List <GetAllScopeClaimsDto> scopeClaims = await Mediator.Send(new GetAllScopeClaimsQuery());

                model.AvailableClaims = scopeClaims.Select(scopeClaim => new SelectListItem
                {
                    Selected = true,
                    Value    = scopeClaim.Id.ToString(),
                    Text     = scopeClaim.Description
                }).ToList();

                return(View(model));
            }

            return(RedirectToAction("List"));
        }
 public static ScopeUpdateModel ToScopeUpdateModel(this GetScopeByIdDto dto)
 {
     return(dto.MapTo <GetScopeByIdDto, ScopeUpdateModel>());
 }