public ActionResult AddCompany(CompanyRequest request) { if (!ModelState.IsValid) { return(CustomResponse(ModelState)); } try { var company = _mapper.Map <CompanyRequest, Company>(request); if (company.Notifications.Any()) { return(CustomResponse(company.Notifications)); } var result = _companyAppService.AddCompany(company); var employeeResponse = _mapper.Map <Company, CompanyResponse>(result); return(CustomResponse(employeeResponse)); } catch (Exception ex) { MessageException(); return(CustomExceptionResponse()); } }
public async Task <IActionResult> Add(CompanyDto company) { var newCompany = await _companyService.AddCompany(company); return(CreatedAtRoute("GetCompanies", new { id = newCompany.Id }, newCompany)); }