public ActionResult Create([Bind(Include="Id,FirstName,LastName,Company,Email,City,Postal,Street,Country,CreatorId,ModificationDate,CreationDate")] Customer customer) { Log.Debug("POST/Create"); if (ModelState.IsValid) { using(var uow = new UoW()){ var customersRepo = uow.GetRepository<ICustomerRepository>(); customersRepo.Add(customer); uow.SaveChanges(); } return RedirectToAction("Index"); } using(var uow = new UoW()){ //ViewBag.CreatorId = new SelectList(uow.IdentityUsers.GetAll(), "Id", "UserName"); } return View(customer); }
public ActionResult DeleteConfirmed(int id) { Log.Debug("POST/DeleteConfirmed Id:{0}", id.ToString()); using(var uow = new UoW()){ var customersRepo = uow.GetRepository<ICustomerRepository>(); var customer = customersRepo.GetByKey((System.Int32)id); customersRepo.Delete(customer); uow.SaveChanges(); } return RedirectToAction("Index"); }
public ActionResult Edit([Bind(Include="Id,FirstName,LastName,Company,Email,City,Postal,Street,Country,CreatorId,ModificationDate,CreationDate")] Customer customer) { Log.Debug("POST/Edit"); if (ModelState.IsValid) { using(var uow = new UoW()){ var customersRepo = uow.GetRepository<ICustomerRepository>(); var customermodify = customersRepo.GetByKey(customer.Id); customermodify.FirstName = customer.LastName; customermodify.LastName = customer.LastName; customermodify.Company = customer.Company; customermodify.Email = customer.Email; customermodify.Street = customer.Street; customermodify.Postal = customer.Postal; customermodify.Country = customer.Country; customermodify.City = customer.City; customersRepo.Update(customermodify); uow.SaveChanges(); return RedirectToAction("Details", new { @id = customer.Id }); } } using(var uow = new UoW()){ //ViewBag.CreatorId = new SelectList(uow.IdentityUsers.GetAll(), "Id", "UserName"); } return View(customer); }