예제 #1
0
        public ActionResult Create(Template template)
        {
            var templateToCreate = new Template();

            Mapper.Map(template, templateToCreate);
            templateToCreate.Seminar = SiteService.GetLatestSeminar(Site, true);

            ModelState.Clear();
            templateToCreate.TransferValidationMessagesTo(ModelState);
            if (ModelState.IsValid)
            {
                // inactivate all old templates
                foreach (var t in _templateRepository.Queryable.Where(a => a.NotificationType == templateToCreate.NotificationType))
                {
                    t.IsActive = false;
                    _templateRepository.EnsurePersistent(t);
                }

                _templateRepository.EnsurePersistent(templateToCreate);

                Message = "Template Created Successfully";

                return(RedirectToAction("Index"));
            }

            var viewModel = TemplateViewModel.Create(Repository, templateToCreate);

            return(View(viewModel));
        }
예제 #2
0
        //
        // GET: /Template/Edit/5
        public ActionResult Edit(int id)
        {
            var template = _templateRepository.GetNullableById(id);

            if (template == null)
            {
                return(RedirectToAction("Index"));
            }

            var viewModel = TemplateViewModel.Create(Repository, template);

            return(View(viewModel));
        }
예제 #3
0
        //
        // GET: /Template/Create
        public ActionResult Create()
        {
            var viewModel = TemplateViewModel.Create(Repository);

            return(View(viewModel));
        }