public ActionResult Create(RoleDTO role) { MethodBase method = MethodBase.GetCurrentMethod(); try { Role newRole = Mapper.Map <Role>(role); newRole.IsValid = true; newRole.Id = 0; var response = RoleRepo.Create(newRole); if (response > 0) { CreateLog(Enums.Success, GetMethodCode(method), LogLevel.Information); return(Ok(response)); } else { CreateLog(Enums.BadRequest, GetMethodCode(method), LogLevel.Warning); return(BadRequest(response)); } } catch (Exception ex) { return(HandleError(ex.Message, GetMethodCode(method))); } }
public IActionResult Create(CreateRoleVM rolevm) { if (ModelState.IsValid) { Role role = rolevm.CreateRole(); _roles.Create(role); return(RedirectToAction("Index")); } return(View()); }
public HttpResponseMessage Ins(RoleInsDTO dto) { if (dto != null) { using (repo) repo.Create(dto.Name); return(Request.CreateResponse(HttpStatusCode.OK)); } return(Request.CreateResponse(HttpStatusCode.NoContent)); }
public OperationResult Create(CreateRole command) { var operationresult = new OperationResult(); if (_roleRepo.Exists(c => c.Name == command.Name)) { return(operationresult.Failed(ApplicationMessage.duplicated)); } var role = new Role(command.Name); _roleRepo.Create(role); _roleRepo.Save(); return(operationresult.Succeeded()); }