Пример #1
0
        public ActionResult Update(int id = 0)
        {
            AppUser appUser = (AppUser)Session["LoggedUser"];

            if (appUser != null)
            {
                Category category = categoryOperation.GetById(id);

                if (category != null)
                {
                    CategoryCRUDModel categoryCRUDModel = new CategoryCRUDModel();

                    categoryCRUDModel.CategoryId = category.CategoryId;
                    categoryCRUDModel.Name       = category.Name;

                    return(View(categoryCRUDModel));
                }
                else
                {
                    return(RedirectToAction("Index", "Category"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
Пример #2
0
        public ActionResult Update(CategoryCRUDModel model)
        {
            if (Session["LoggedUser"] != null)
            {
                Category category = categoryOperation.GetById(model.CategoryId);

                category.CategoryId = model.CategoryId;
                category.Name       = model.Name;

                categoryOperation.Update(category);
            }

            return(RedirectToAction("Index", "Category"));
        }
Пример #3
0
        public ActionResult Insert(CategoryCRUDModel model)
        {
            AppUser appUser = (AppUser)Session["LoggedUser"];

            if (appUser != null)
            {
                Category category = new Category()
                {
                    AppUserId = appUser.AppUserId,

                    CategoryId = model.CategoryId,
                    Name       = model.Name,
                    IsActive   = true
                };
                categoryOperation.Insert(category);

                return(RedirectToAction("Index", "Category"));
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }