public IHttpActionResult Put(int roleId, RoleWriteModel model) { if (string.IsNullOrWhiteSpace(model.CodeName)) { return(BadRequest("No codename provided.")); } if (string.IsNullOrWhiteSpace(model.DisplayName)) { return(BadRequest("No display name provided.")); } var role = _roleRepository.FindById(roleId); if (role == null) { return(NotFound()); } _roleMapper.Map(model, role); _roleRepository.Save(role); return(NoContent()); }
public IHttpActionResult Post(RoleWriteModel model) { if (string.IsNullOrWhiteSpace(model.CodeName)) { return(BadRequest("No codename provided.")); } if (string.IsNullOrWhiteSpace(model.DisplayName)) { return(BadRequest("No display name provided.")); } var role = _roleFactory.CreateRole(model.CodeName, model.DisplayName); _roleMapper.Map(model, role); _roleRepository.Save(role); var result = Mapper.Map <RoleReadModel>(role); return(CreatedAtRoute("GetRole", new { roleId = role.Id }, result)); }
public void Map(RoleWriteModel model, Role entity) { entity.CodeName = model.CodeName; entity.DisplayName = model.DisplayName; }