public async Task <IActionResult> PostAsync(int userId, [FromBody] SaveEnterpriseResource resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } var enterprise = mapper.Map <SaveEnterpriseResource, Enterprise>(resource); var result = await enterpriseService.SaveAsync(userId, enterprise); if (!result.Success) { return(BadRequest(result.Message)); } var enterpriseResource = mapper.Map <Enterprise, EnterpriseResource>(result.Resource); return(Ok(enterpriseResource)); }
public async Task <IActionResult> PutOrPost([FromBody] EnterpriseDTOFull enterpriseDTO) { var item = await _enterpriseService.SaveAsync(enterpriseDTO); return(CreatedAtAction(nameof(Get), new { id = item.Id }, item)); }