public IActionResult Create(CreateAreaModel model) { var validationResult = _service.ValidateCreateArea(User, model); if (!validationResult.Valid) { return(BadRequest(validationResult.Result)); } var entity = _service.CreateArea(model); context.SaveChanges(); return(Created($"/{ApiEndpoint.AREA_API}?id={entity.Id}", new AppResultBuilder().Success(entity.Id))); }
public async Task <IHttpActionResult> CreateArea(AreaCreate area) { //check if model is valid if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //instantiate area service AreaService service = CreateAreaService(); if (await service.CreateArea(area) == false) { return(InternalServerError()); } return(Ok()); //200 }