Exemplo n.º 1
0
        public ActionResult Add(CategoryAddVM viewModel)
        {
            if (!ModelState.IsValid)
            {
                TempData.SetStatusMessage(Constants.Message.Oops, StatusMessageType.Danger);
                InitialAddVM(viewModel);
                return View(viewModel);
            }

            var result = _categoryRepository.Add(viewModel);
            if (result.IsSuccess)
            {
                TempData.SetStatusMessage(result.Message);
                return RedirectToAction("Index");
            }

            TempData.SetStatusMessage(result.Message, StatusMessageType.Danger);
            InitialAddVM(viewModel);
            return View(viewModel);
        }
Exemplo n.º 2
0
 public ActionResult Add()
 {
     var viewModel = new CategoryAddVM();
     InitialAddVM(viewModel);
     return View(viewModel);
 }
Exemplo n.º 3
0
 private void InitialAddVM(CategoryAddVM viewModel)
 {
     viewModel.Categories = _categoryRepository.Get(x => !x.IsDelete && x.IsPublish).OrderBy(x => x.Title).ToList();
 }