public async Task <RoleCategoryForListDto> Update(RoleCategoryForCreationAndUpdateDto roleCategoryForCreationAndUpdateDto) { var roleCategory = await roleCategoryDal.GetAsync(x => x.Id == roleCategoryForCreationAndUpdateDto.Id); if (roleCategory == null) { throw new RestException(HttpStatusCode.BadRequest, new { RoleCategoryListNotFound = Messages.NotFound }); } var updatedRoleCategory = mapper.Map(roleCategoryForCreationAndUpdateDto, roleCategory); await roleCategoryDal.Update(updatedRoleCategory); return(mapper.Map <RoleCategory, RoleCategoryForListDto>(updatedRoleCategory)); }
public async Task <RoleCategoryForListDto> Create(RoleCategoryForCreationAndUpdateDto roleCategoryForCreationAndUpdateDto) { var checkFromRepo = await roleCategoryDal.GetAsync(x => x.Name == roleCategoryForCreationAndUpdateDto.Name); if (checkFromRepo != null) { throw new RestException(HttpStatusCode.BadRequest, new { RoleCategoryListNotFound = Messages.AlreadyExist }); } var roleCategoryCreated = mapper.Map <RoleCategory>(roleCategoryForCreationAndUpdateDto); await roleCategoryDal.Add(roleCategoryCreated); return(mapper.Map <RoleCategory, RoleCategoryForListDto>(roleCategoryCreated)); }
public async Task <ActionResult <RoleCategoryForListDto> > Update(RoleCategoryForCreationAndUpdateDto roleCategoryForCreationAndUpdateDto) { return(await roleCategoryService.Update(roleCategoryForCreationAndUpdateDto)); }