public ActionResult Edit(int id)
        {
            var model = new CategoryCrudViewModel();

            model = _category_Service.Find(id);
            return(View("~/Areas/Admin/Views/Category/Crud.cshtml", model));
        }
Esempio n. 2
0
        public CategoryCrudViewModel Find(int id)
        {
            var _data = _categoryManager.GetById(id);
            var model = new CategoryCrudViewModel();

            model.Id              = _data.Id;
            model.Name            = _data.Name;
            model.Alias           = _data.Alias;
            model.Status          = _data.Status;
            model.MetaKeyWord     = _data.MetaKeyWord;
            model.MetaDescription = _data.MetaDescription;
            return(model);
        }
        public ActionResult Save(CategoryCrudViewModel model)
        {
            int id = 0;

            if (!string.IsNullOrEmpty(model.Id.ToString()) && model.Id > 0)
            {
                id = _category_Service.UpdateCategory(model);
            }
            else
            {
                id = _category_Service.CreateCategory(model);
            }
            return(RedirectToAction("Edit", new { id = id }));
        }
Esempio n. 4
0
 public int CreateCategory(CategoryCrudViewModel model)
 {
     try
     {
         var _saveData = new Category();
         _saveData.Name            = model.Name;
         _saveData.Alias           = model.Name.GenerateFriendlyName();
         _saveData.Status          = model.Status;
         _saveData.MetaKeyWord     = model.MetaKeyWord;
         _saveData.MetaDescription = model.MetaDescription;
         _categoryManager.Add(_saveData);
         _categoryManager.Save();
         return(_saveData.Id);
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
        public ActionResult Create()
        {
            var model = new CategoryCrudViewModel();

            return(View("~/Areas/Admin/Views/Category/Crud.cshtml", model));
        }