Exemple #1
0
        public ActionResult LoadPaperForm(int paperId)
        {
            IPaperFacade paperFacade = FacadeFactory.Instance.Create <IPaperFacade>();

            PaperVM paperVM = null;

            if (paperId != -1)
            {
                var paperDTOResult = paperFacade.GetPaperById(paperId);

                if (paperDTOResult.IsValid())
                {
                    paperVM             = new PaperVM();
                    paperVM.PaperId     = paperDTOResult.Data.PaperId;
                    paperVM.Name        = paperDTOResult.Data.Name;
                    paperVM.Description = paperDTOResult.Data.Description;
                    paperVM.Duration    = paperDTOResult.Data.Duration;
                }
                else
                {
                    return(new RedirectResult("Error/"));
                }
            }
            else
            {
                paperVM             = new PaperVM();
                paperVM.PaperId     = -1;
                paperVM.Name        = "";
                paperVM.Description = "";
                paperVM.Duration    = 1;
            }

            return(PartialView(paperVM));
        }
Exemple #2
0
        public ActionResult Details(int id)
        {
            IPaperFacade paperFacade = FacadeFactory.Instance.Create <IPaperFacade>();

            PaperDetailsVM paperDetails = null;

            var questionsOfPaper = paperFacade.GetQuestionsOfPaper(id);
            var paper            = paperFacade.GetPaperById(id);

            if (paper.IsValid() && questionsOfPaper.IsValid())
            {
                paperDetails             = new PaperDetailsVM();
                paperDetails.PaperId     = id;
                paperDetails.Name        = paper.Data.Name;
                paperDetails.Description = paper.Data.Description;
                paperDetails.Duration    = paper.Data.Duration;
                paperDetails.Questions   = new List <QuestionVM>();
                foreach (var question in questionsOfPaper.Data)
                {
                    QuestionVM questionVM = new QuestionVM();
                    questionVM.QuestionId      = question.QuestionId;
                    questionVM.Text            = question.Text;
                    questionVM.Marks           = question.Marks;
                    questionVM.QuestionPaperNo = id;

                    paperDetails.Questions.Add(questionVM);
                }
            }
            return(View(paperDetails));
        }