예제 #1
0
        public ActionResult AddProductHeadline()
        {
            var viewModel = new ProductHeadlineViewModel();

            return View(viewModel);
        }
예제 #2
0
        public ActionResult EditProductHeadline(int productHeadlineId)
        {
            var productHeadline = _productHeadlineRepository.Get(productHeadlineId);

            var viewModel = new ProductHeadlineViewModel
            {
                Id = productHeadline.Id,
                Name = productHeadline.Name
            };

            return View(viewModel);
        }
예제 #3
0
        public ActionResult EditProductHeadline(ProductHeadlineViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage))
                {
                    _orchardServices.Notifier.Error(T(error));
                }
                return RedirectToAction("EditProductHeadline", new {productHeadlineId = viewModel.Id});
            }

            var productHeadline = _productHeadlineRepository.Get(viewModel.Id);
            productHeadline.Name = viewModel.Name;
            _productHeadlineRepository.Update(productHeadline);

            _orchardServices.Notifier.Information(T("Product Headline has been edited."));
            return RedirectToAction("Index");
        }