예제 #1
0
        public IUnitOfWorkResult AddCompany(Company model)
        {
            var repo = RepoGeneric;

            repo.Add<Company>(model);

            return repo.UnitOfWork.SaveChanges();
        }
예제 #2
0
        public ActionResult Add(Company model)
        {
            if (ModelState.IsValid)
            {
                Manager.AddCompany(model);

                return RedirectToAction("Index");
            }

            return View(model);
        }
예제 #3
0
        public ActionResult Edit(int id, Company model)
        {
            if (ModelState.IsValid)
            {
                Manager.EditCompany(model);

                return RedirectToAction("Index");
            }
            else
            {
                return View(model);
            }
        }
예제 #4
0
        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();
        }