public ActionResult Create(Company company) { if (ModelState.IsValid) { db.Companies.Add(company); db.SaveChanges(); return RedirectToAction("Index"); } return View(company); }
public CompanyDto AddCompany(CompanyDto companyDto) { var company = new Company { Name = companyDto.Name, Notes = companyDto.Notes }; var addedCompany = _context.Companies.Add(company); _context.SaveChanges(); var addedCompanyDto = Mapper.Map<Company, CompanyDto>(addedCompany); return addedCompanyDto; }
public ActionResult Edit(Company company) { if (ModelState.IsValid) { db.Entry(company).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(company); }