public ActionResult LoadQuestionForm(int questionId) { IQuestionFacade questionFacade = FacadeFactory.Instance.Create <IQuestionFacade>(); QuestionVM questionVM = null; if (questionId != -1) { var questionDTOResult = questionFacade.GetQuestionById(questionId); if (questionDTOResult.IsValid()) { questionVM = new QuestionVM(); questionVM.QuestionId = questionDTOResult.Data.QuestionId; questionVM.Text = questionDTOResult.Data.Text; questionVM.Marks = questionDTOResult.Data.Marks; questionVM.QuestionPaperNo = questionDTOResult.Data.QuestionPaperNo; } else { return(new RedirectResult("Error/")); } } else { questionVM = new QuestionVM(); questionVM.QuestionId = -1; questionVM.Text = ""; questionVM.Marks = 1; questionVM.QuestionPaperNo = 1; } return(PartialView(questionVM)); }
public ActionResult Edit(int QuestionId) { var list = new QuestionViewModel(); list.QuestionIsActiveList = new List <SelectListItem>(); list.QuestionIsActiveList.Add(new SelectListItem() { Text = "Active", Value = "true" }); list.QuestionIsActiveList.Add(new SelectListItem() { Text = "Inactive", Value = "false" }); var questionVM = new QuestionViewModel(); _questionFacade = new QuestionFacade(); if (QuestionId != null && QuestionId != 0) { var questionItemEntity = _questionFacade.GetQuestionById(QuestionId); questionVM.QuestionId = questionItemEntity.QuestionId; questionVM.QuestionName = questionItemEntity.QuestionName; questionVM.Status = questionItemEntity.Status; if (questionItemEntity.CreateDate != null) { questionVM.CreateDate = (DateTime)questionItemEntity.CreateDate; } if (questionItemEntity.UpdateDate != null) { questionVM.UpdateDate = (DateTime)questionItemEntity.UpdateDate; } questionVM.CreateUserName = questionItemEntity.CreateUserName; questionVM.UpdateUserName = questionItemEntity.UpdateUserName; questionVM.QuestionIsActiveList = list.QuestionIsActiveList; questionVM.CreateUser = questionItemEntity.CreateUser; questionVM.UpdateUser = questionItemEntity.UpdateUser; } return(View(questionVM)); }