コード例 #1
0
        public ActionResult Create()
        {
            var model = new SetOfBookModel();

            model.CompanyId = AuthenticationHelper.User.CompanyId;
            return(View(model));
        }
コード例 #2
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));
        }
コード例 #3
0
        public ActionResult Create()
        {
            var model = new SetOfBookModel();

            model.CompanyId = AuthenticationHelper.CompanyId.Value;
            ViewBag.Title   = "Create Book";
            return(View("Edit", model));
        }
コード例 #4
0
 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
     });
 }
コード例 #5
0
        public ActionResult Edit(SetOfBookModel model)
        {
            if (ModelState.IsValid)
            {
                string result = service.Update(MapModel(model));
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
コード例 #6
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
            });
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        public ActionResult Edit(string id)
        {
            SetOfBookModel model = new SetOfBookModel(service.GetSingle(id, AuthenticationHelper.User.CompanyId));

            return(View(model));
        }
コード例 #9
0
 public static string Update(SetOfBookModel model)
 {
     return(service.Update(getEntityByModel(model)));
 }
コード例 #10
0
 public static string Insert(SetOfBookModel model)
 {
     return(service.Insert(getEntityByModel(model)));
 }
コード例 #11
0
        public static SetOfBookModel GetSetOfBook(string id)
        {
            SetOfBookModel model = new SetOfBookModel(service.GetSingle(id, AuthenticationHelper.CompanyId.Value));

            return(model);
        }