Пример #1
0
        public IActionResult CreateDetail(CaseStudySpecViewModel model)
        {
            ViewBag.CaseStudy = _caseStudyRepository.GetAllCaseStudies();
            if (ModelState.IsValid)
            {
                var detail = _mapper.Map <CaseStudySpecViewModel, CaseStudySpec>(model);

                detail.AddedBy = _admin.Fullname;

                _caseStudyRepository.CreateCaseStudySpec(detail);

                return(RedirectToAction("detailtable"));
            }
            return(View(model));
        }
Пример #2
0
        public IActionResult EditDetail(CaseStudySpecViewModel model)
        {
            ViewBag.CaseStudy = _caseStudyRepository.GetAllCaseStudies();

            if (ModelState.IsValid)
            {
                var detail         = _mapper.Map <CaseStudySpecViewModel, CaseStudySpec>(model);
                var detailToUpdate = _caseStudyRepository.GetAllCaseStudySpecsById(model.Id);
                if (detailToUpdate == null)
                {
                    return(NotFound());
                }
                detailToUpdate.ModifiedBy = _admin.Fullname;

                _caseStudyRepository.UpdateCaseStudySpec(detailToUpdate, detail);

                return(RedirectToAction("detailtable"));
            }
            return(View(model));
        }