示例#1
0
        public ActionResult AddCategory(CategoryModel model)
        {
            var category = new Category();

            if (ModelState.IsValid)
            {
                category.Description = model.Description;
                category.InsertDate = DateTime.Now;
                category.InsertUserId = CustomMembership.CurrentUser().Id;
                category.IsActive = model.IsActive;
                category.Name = model.Name;
                category.Order = model.Order;
                category.Slug = StringManager.ToSlug(model.Name);

                try
                {
                    _categoryService.Insert(category);
                    _uow.SaveChanges();

                    messagesForView.Clear();
                    messagesForView.Add("İşlemi başarılı!");
                    Success(messagesForView);

                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    messagesForView.Clear();
                    messagesForView.Add("İşlem başarısız!");
                    messagesForView.Add(ex.Message);
                    messagesForView.Add(ex.InnerException.Message);
                    Error(messagesForView);
                }
            }

            return View(model);
        }
示例#2
0
 public void Update(Category category)
 {
     _categoryRepository.Update(category);
 }
示例#3
0
 public void Insert(Category category)
 {
     _categoryRepository.Insert(category);
 }
示例#4
0
 public void Delete(Category category)
 {
     _categoryRepository.Delete(category);
 }