public ActionResult Edit(SetOfBookModel model) { if (ModelState.IsValid) { if (model.Id > 0) { string result = SetOfBookHelper.Update(model); return RedirectToAction("Index"); } else { if (SetOfBookHelper.GetSetOfBookByName(model.Name) == null) { string result = SetOfBookHelper.Insert(model); return RedirectToAction("Index"); } else { ModelState.AddModelError("Error", "Set of Book Already exists."); } } } return View(model); }
public ActionResult Create() { var model = new SetOfBookModel(); model.CompanyId = AuthenticationHelper.CompanyId.Value; ViewBag.Title = "Create Book"; return View("Edit", model); }
private static SetOfBook getEntityByModel(SetOfBookModel model) { if (model == null) return null; return new SetOfBook { CompanyId = AuthenticationHelper.CompanyId.Value, Id = model.Id, Name = model.Name }; }
public static string Update(SetOfBookModel model) { return service.Update(getEntityByModel(model)); }
public static string Insert(SetOfBookModel model) { return service.Insert(getEntityByModel(model)); }
public static SetOfBookModel GetSetOfBook(string id) { SetOfBookModel model = new SetOfBookModel(service.GetSingle(id, AuthenticationHelper.CompanyId.Value)); return model; }