Exemplo n.º 1
0
        public async Task <RoleDto> Handle(CreateRoleCommand request, CancellationToken cancellationToken)
        {
            var role   = _mapper.Map <Role>(request.CreateRoleDto);
            var result = await _repository.Create(role);

            return(_mapper.Map <RoleDto>(result));
        }
Exemplo n.º 2
0
 public ActionResult Create(FormCollection collection)
 {
     try
     {
         rolesRepo.Create(collection);
         ViewBag.ResultMessage = "Role created successfully !";
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public async Task <ActionResult> Create(IdentityRoleVM role)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(role));
                }
                var model  = new IdentityRole(role.Name);
                var result = await _repo.Create(model);

                if (result != string.Empty)
                {
                    return(RedirectToAction(nameof(Details), new { id = result }));
                }
            }
            catch (Exception x)
            {
                ModelState.AddModelError(string.Empty, x.InnerException.Message);
            }
            return(View(role));
        }