public IUnitOfWorkResult AddCompany(Company model) { var repo = RepoGeneric; repo.Add<Company>(model); return repo.UnitOfWork.SaveChanges(); }
public ActionResult Add(Company model) { if (ModelState.IsValid) { Manager.AddCompany(model); return RedirectToAction("Index"); } return View(model); }
public ActionResult Edit(int id, Company model) { if (ModelState.IsValid) { Manager.EditCompany(model); return RedirectToAction("Index"); } else { return View(model); } }
public IUnitOfWorkResult EditCompany(Company model) { var repo = RepoGeneric; var company = repo.FindOne<Company>(c => c.CompanyId == model.CompanyId); if (company == null) throw new Exception("Company doesn't exist"); company.Name = model.Name; company.Description = model.Description; return repo.UnitOfWork.SaveChanges(); }