public IActionResult Post([FromBody] Company company) { try { var Company = _companyServices.Add(company); return(Ok(Company)); } catch (Exception ex) { ModelState.AddModelError("PostCompany", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Add(CompanyAddModel companyAddModel) { if (!ModelState.IsValid) { return(View(companyAddModel)); } else { Company company = new Company { CompanyName = companyAddModel.CompanyName }; ICompanyServices.Add(company); return(RedirectToAction("Index", "Company")); } }