public IActionResult UpdateQuestionToDatabase(Question flashToUpdate) { var repo = new QuestionRepo(); repo.UpdateQuestion(flashToUpdate); return(RedirectToAction("ListAll")); }
public IActionResult DeleteQuestion(int id) { var repo = new QuestionRepo(); repo.DeleteQuestion(id); return(RedirectToAction("ListAll")); }
public IActionResult UpdateFlash(int id) { var repo = new QuestionRepo(); var question = repo.GetQuestion(id); return(View(question)); }
public IActionResult Index() { QuestionRepo repo = new QuestionRepo(); List <Question> question = repo.GetAllQuestions(); return(View(question)); }
public IActionResult InsertQuestionToDatabase(Question flashToInsert) { var repo = new QuestionRepo(); repo.InsertFlash(flashToInsert); return(RedirectToAction("ListAll")); }
public ActionResult Create(QuestionViewModel model) { HttpPostedFileBase file = model.imgurl; var path = ""; if (file != null) { if (file.ContentLength > 0) { // Untuk Mengecek apakah file berformat gambar if ((Path.GetExtension(file.FileName).ToLower() == ".jpg") || (Path.GetExtension(file.FileName).ToLower() == ".png") || (Path.GetExtension(file.FileName).ToLower() == ".gif") || (Path.GetExtension(file.FileName).ToLower() == ".jpeg")) { path = Path.Combine(Server.MapPath("~/Images"), file.FileName); file.SaveAs(path); } } model.imageUrl = file.FileName; } ResponseResult result = QuestionRepo.Update(model); return(Json(new { success = result.Success, message = result.ErrorMessage, entity = result.Entity }, JsonRequestBehavior.AllowGet)); }
public async Task <Question> GetQuestionWithAnswer(int id) { var question = await QuestionRepo.GetAsync(id); question.Answers = await AnswersRepo.FindBy(a => a.QuestionId == id).ToListAsync(); return(question); }
public async Task <ActionResult <Question> > Get(int id) { if (await QuestionRepo.GetQuestionById(id) is Question question) { return(question); } return(NotFound()); }
public async Task <ActionResult <int> > GetLastQuestionAdded() { var lastQuestion = await QuestionRepo.GetLastQuestionAdded(); if (lastQuestion != 0) { return(Ok(lastQuestion)); } return(NotFound()); }
public async Task <IActionResult> Delete(int id) { var success = await QuestionRepo.DeleteQuestion(id); if (!success) { return(NotFound()); } return(NoContent()); }
public async Task <ActionResult <IEnumerable <Question> > > Get() { var questions = await QuestionRepo.GetQuestions(); if (questions == null) { return(NotFound()); } return(Ok(questions)); }
public ActionResult Delete(QuestionViewModel model) { ResponseResult result = QuestionRepo.Delete(model); return(Json(new { success = result.Success, message = result.ErrorMessage, entity = result.Entity }, JsonRequestBehavior.AllowGet)); }
public async Task <Exam> GetExamwithQuestionsWithAnswers(int id) { var exam = await ExamRepo.GetAsync(id); var questions = await QuestionRepo.FindBy(a => a.ExamId == id).ToListAsync(); foreach (var q in questions) { q.Answers = await AnswersRepo.FindBy(a => a.QuestionId == q.Id).ToListAsync(); } return(exam); }
public ActionResult Delete(QuestionViewModel model) { var userid = (long)Session["userid"]; ResponResultViewModel result = QuestionRepo.Update(model, userid); return(Json(new { success = result.Success, message = result.Message, entity = result.Entity }, JsonRequestBehavior.AllowGet)); }
public List <QuestionOptions> DeleteQuestionOption(int QuestionId, int OptionId) { QuestionRepo repo = new QuestionRepo(); bool result = repo.DeleteQuestionOption(QuestionId, OptionId); if (result) { return(repo.LoadQuestionOptions(QuestionId)); } else { return(null); } }
public async Task <IActionResult> Post([FromBody] Question question) { try { var id = await QuestionRepo.CreateQuestion(question); Question model = await QuestionRepo.GetQuestionById(id); return(CreatedAtRoute("Get", new { Id = id }, model)); } catch (ArgumentException ex) { return(BadRequest(ex.Message)); } }
/// <summary> /// View selected & non-selected question for provided course & exam /// </summary> public ActionResult ManageQuestions(int examId, int courseId) { int userId = Utilities.GetInstance().GetCurrentUserId(); //ExamQuestion examQuestion = db.ExamQuestions.Where(e => e.ExamId == examId & e.Exam.UserId == userId).FirstOrDefault(); int[] _examQuestions = Utilities.GetInstance().GetExamQuestion(examId); ViewBag.ExamQuestions = _examQuestions; // new SelectList(_examQuestions, "Id", "QuestionText"); ViewBag.ExamId = examId; ViewBag.ExamTitle = db.Exam.Where(p => p.Id == examId).FirstOrDefault().Title; var cls = db.CourseClass.FirstOrDefault(p => p.Id == courseId); ViewBag.CourseTitle = cls.Title; ViewBag.Questions = new SelectList(QuestionRepo.GetInstance().GetQuestionByCourse(cls.CourseId), "Id", "QuestionText"); return(View()); }
public Tuple <Quiz, List <Questions> > DeleteQuizQuestions(string QuizId, string QuestionId) { QuestionRepo repo = new QuestionRepo(); int QuizID = 0; int QuestionID = 0; int.TryParse(QuizId, out QuizID); int.TryParse(QuestionId, out QuestionID); bool result = repo.DeleteQuestion(QuizID, QuestionID); if (result) { return(repo.LoadAllQuizQuestions(QuizID)); } else { return(null); } }
public CustomResponse AddQuestionOptions(List <QuestionOptions> Options) { CustomResponse response = new CustomResponse(); try { QuestionRepo rep = new QuestionRepo(); var list = rep.SaveQuestionOptions(Options); if (list != null) { response.Success = true; response.Message = "Options saved successfully"; } } catch (Exception ex) { response.Success = false; response.Message = "Error occured while saving question options"; } return(response); }
public UnitOfWork(ExamicaDbContext _context) { context = _context; Answers = new AnswerRepo(_context); AppUsers = new AppUserRepo(_context); ComplexQuestions = new ComplexQuestionRepo(_context); ExamAppUsers = new ExamAppUserRepo(_context); ExamComplexQuestions = new ExamComplexQuestionRepo(_context); ExamQuestions = new ExamQuestionRepo(_context); Exams = new ExamRepo(_context); Options = new OptionRepo(_context); OrganizationAdmins = new OrganizationAdminRepo(_context); organizationExaminees = new OrganizationExamineeRepo(_context); OrganizationExaminers = new OrganizationExaminerRepo(_context); OrganizationObservers = new OrganizationObsereverRepo(_context); Organizations = new OrganizationRepo(_context); QuestionComplexQuestions = new QuestionComplexQuestionRepo(_context); Questions = new QuestionRepo(_context); QuestionOptions = new QuestionOptionRepo(_context); Results = new ResultRepo(_context); PricingPlans = new PricingPlanRepo(_context); }
public UnitOfWork(GoldStreamerContext e, bool DropDB = false) { if (DropDB) { DropDatabase(e); } if (e != null) { entities = e; } else { entities = new GoldStreamerContext(); } TraderRepo = new TraderRepo <Trader>(this.entities); TradePricesRepo = new TraderPricesRepo <TraderPrices>(this.entities); PriceViewerRepo = new PricerRepo <Prices>(this.entities); BasketRepo = new BasketRepo <Basket>(this.entities); BasketPricesRepo = new BasketPricesRepo <BasketPrices>(this.entities); BasketTradersRepo = new BasketTradersRepo <BasketTraders>(this.entities); TraderFavRepo = new TraderFavRepo <TraderFavorites>(this.entities); FavorateListRepo = new FavoriteListRepo <FavoriteList>(this.entities); UsersRepo = new UsersRepo <Users>(this.entities); GovernorateRepo = new GovernorateRepo(this.entities); CityRepo = new CityRepo(this.entities); RegionRepo = new RegionRepo(this.entities); RolePermissionRepo = new RolePermissionRepo <RolePermission>(this.entities); FeedbackRepo = new FeedbackRepo <Feedback>(this.entities); QuestionGroupRepo = new QuestionGroupRepo <QuestionGroup>(this.entities); QuestionRepo = new QuestionRepo <Question>(this.entities); SubscribeRepo = new SubscribeRepo <Subscribe>(this.entities); NewsMainCategoryRepo = new NewsMainCategoryRepo <NewsMainCategory>(this.entities); NewsCategoryRepo = new NewsCategoryRepo <NewsCategory>(this.entities); NewsRepo = new NewsRepo <News>(this.entities); GlobalPriceRepo = new GlobalPriceRepo <GlobalPrice>(entities); TraderPricesChartRepo = new TraderPricesChartRepo <TraderPricesChart>(entities); DollarRepo = new DollarRepo <Dollar>(entities); }
public async Task Clone(Exam item) { var newItem = new Exam { Id = 0, Active = true, DurationMinutes = item.DurationMinutes, Login = item.Login, MaxStart = item.MaxStart, MinStart = item.MinStart, Name = $"{item.Name} ({DateTime.Now})", Questions = null, Users = null }; newItem.Code = await GetNewGiud(); var examId = await ExamRepo.AddAsync(newItem); foreach (var q in item.Questions) { var answers = q.Answers; q.ExamId = examId; q.Id = 0; q.Answers = null; var qId = await QuestionRepo.AddAsync(q); foreach (var a in answers) { a.QuestionId = qId; a.Id = 0; await AnswersRepo.AddAsync(a); } } await ExamRepo.SaveChangesAsync(); }
public Tuple <Quiz, List <Questions> > LoadQuizQuestions(int QuizId) { QuestionRepo rep = new QuestionRepo(); return(rep.LoadAllQuizQuestions(QuizId)); }
public ActionResult Delete(int id) { return(PartialView("_Delete", QuestionRepo.GetQuestion(id))); }
public ActionResult List(string search) { return(PartialView("_List", QuestionRepo.All(search))); }
public QuestionController() { QuestionRepo repository = new QuestionRepo(); _service = new QuestionService(repository); }
public ActionResult AddQuestion(long id) { ViewBag.QuestionList = new SelectList(QuestionRepo.All(""), "id", "question"); return(PartialView("_AddQuestion", Document_Test_DetailRepo.By(id))); }
public IEnumerable <Question> GetQuestionsByCategory(int id) { return(QuestionRepo.GetQuestionsByCategoryId(id)); }
public Questions AddQuestion(Questions Question) { QuestionRepo rep = new QuestionRepo(); return(rep.Add(Question)); }
public List <QuestionOptions> LoadQuestionOptions(int QuestionId) { QuestionRepo repo = new QuestionRepo(); return(repo.LoadQuestionOptions(QuestionId)); }