コード例 #1
0
        public PartialViewResult AddConferenceCategory()
        {
            var model      = new ConferenceCategoryViewModel();
            var conference = _unitOfWork.ConferenceRepository.FirstOrDefault(o => o.IsActive);

            if (conference == null)
            {
                ModelState.AddModelError("", "No started conference");
                ViewBag.IsCallValidationSummary = true;
                return(PartialView("_AddConferenceCategory", model));
            }
            model.Categories = GetConferenceCategories(conference.Id);
            return(PartialView("_AddConferenceCategory", model));
        }
コード例 #2
0
        public PartialViewResult AddConferenceCategory(ConferenceCategoryViewModel model)
        {
            if (ModelState.IsValid)
            {
                var conference = _unitOfWork.ConferenceRepository.FirstOrDefault(o => o.IsActive);

                _unitOfWork.ConferenceCategoryRepository.Insert(new ConferenceCategoryModel
                {
                    ConferenceId = conference.Id,
                    Name         = model.CategoryName,
                    CreatedAt    = DateTime.Now.ToString(),
                    UpdatedAt    = DateTime.Now.ToString(),
                    IsActive     = true
                });
                _unitOfWork.Save();
                ModelState.Clear();
                model.Categories          = GetConferenceCategories(conference.Id);
                model.CategoryName        = null;
                ViewBag.IsCategoryCreated = true;
                return(PartialView("_AddConferenceCategory", model));
            }
            return(PartialView("_AddConferenceCategory", model));
        }