Пример #1
0
        public ActionResult Edit(Guid id, SubjectViewModel viewModel)
        {
            var knowledgeAreaRepository = new KnowledgeAreaRepository(_context);
            var subjectRepository       = new SubjectRepository(_context);


            if (ModelState.IsValid)
            {
                try
                {
                    var knowledgeArea = knowledgeAreaRepository.GetById(id);
                    subjectRepository.Update(SubjectViewModel.ToEntity(viewModel, knowledgeArea));
                    _context.Save(_loggedUser);

                    TempData["MessageType"]  = "success";
                    TempData["MessageTitle"] = Resource.ContentManagementToastrTitle;
                    TempData["Message"]      = "Subject updated";
                    return(Redirect(TempData["BackURL"].ToString()));
                }
                catch (Exception ex)
                {
                    TempData["MessageType"]  = "error";
                    TempData["MessageTitle"] = Resource.ContentManagementToastrTitle;
                    TempData["Message"]      = ex.Message;
                }
            }

            var knowledgeAreas = knowledgeAreaRepository.ListActiveKnowledgeAreas();

            ViewBag.KnowledgeAreas = new SelectList(knowledgeAreas, "Id", "Name");
            return(View(viewModel));
        }
        public ActionResult Edit(Guid id)
        {
            var knowledgeAreaRepository = new KnowledgeAreaRepository(_context);
            var area = knowledgeAreaRepository.GetById(id);

            return(View(KnowledgeAreaViewModel.FromEntity(area, 0)));
        }
Пример #3
0
        public ActionResult KnowledgeAreaPanel(Guid id)
        {
            var knowledgeAreaRepository = new KnowledgeAreaRepository(_context);
            var knowledgeArea           = knowledgeAreaRepository.GetById(id);
            var viewModel = KnowledgeAreaViewModel.FromEntity(knowledgeArea, 2);

            return(PartialView("_KnowledgeAreaPanel", viewModel));
        }