Esempio n. 1
0
 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));
     }
 }
Esempio n. 2
0
        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"));
            }
        }