public ActionResult EditPublisher(PublishersEditPublisherVM model) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); PublishersRepository publishersRepository = new PublishersRepository(context); Publisher publisher = null; if (!ModelState.IsValid) { return(View(model)); } else { if (model.ID > 0) { publisher = publishersRepository.GetByID(model.ID); } else { publisher = new Publisher(); } publisher.ID = model.ID; publisher.Name = model.Name; publisher.Address = model.Address; publishersRepository.Save(publisher); } return(RedirectToAction("Index", "Publishers")); }
public ActionResult EditPublisher(PublishersEditPublisherVM model) { LibraryManagementSystemContext context = new LibraryManagementSystemContext(); PublishersRepository publishersRepository = new PublishersRepository(context); Publisher publisher = null; if (!ModelState.IsValid) { return View(model); } else { if (model.ID > 0) { publisher = publishersRepository.GetByID(model.ID); } else { publisher = new Publisher(); } publisher.ID = model.ID; publisher.Name = model.Name; publisher.Address = model.Address; publishersRepository.Save(publisher); } return RedirectToAction("Index", "Publishers"); }