コード例 #1
0
        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);
        }
コード例 #2
0
 public ActionResult Create()
 {
     var model = new SetOfBookModel();
     model.CompanyId = AuthenticationHelper.CompanyId.Value;
     ViewBag.Title = "Create Book";
     return View("Edit", model);
 }
コード例 #3
0
        private static SetOfBook getEntityByModel(SetOfBookModel model)
        {
            if (model == null) return null;

            return new SetOfBook
            {
                CompanyId = AuthenticationHelper.CompanyId.Value,
                Id = model.Id,
                Name = model.Name
            };
        }
コード例 #4
0
 public static string Update(SetOfBookModel model)
 {
     return service.Update(getEntityByModel(model));
 }
コード例 #5
0
 public static string Insert(SetOfBookModel model)
 {
     return service.Insert(getEntityByModel(model));
 }
コード例 #6
0
 public static SetOfBookModel GetSetOfBook(string id)
 {
     SetOfBookModel model = new SetOfBookModel(service.GetSingle(id, AuthenticationHelper.CompanyId.Value));
     return model;                
 }