public ActionResult Create() { var model = new SetOfBookModel(); model.CompanyId = AuthenticationHelper.User.CompanyId; return(View(model)); }
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 SetOfBook MapModel(SetOfBookModel model) ////TODO: this should be done in service will discuss later - FK { return(new SetOfBook { Id = model.Id, CompanyId = model.CompanyId, Name = model.Name }); }
public ActionResult Edit(SetOfBookModel model) { if (ModelState.IsValid) { string result = service.Update(MapModel(model)); return(RedirectToAction("Index")); } return(View(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 ActionResult Create(SetOfBookModel model) { if (ModelState.IsValid) { SetOfBook duplicateRecord = service.GetSetOfBook(AuthenticationHelper.User.CompanyId, model.Name); if (duplicateRecord == null) { string result = service.Insert(MapModel(model)); return(RedirectToAction("Index")); } else { ModelState.AddModelError("Error", "Set of Book Already exists."); } } return(View(model)); }
public ActionResult Edit(string id) { SetOfBookModel model = new SetOfBookModel(service.GetSingle(id, AuthenticationHelper.User.CompanyId)); return(View(model)); }
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); }