//выводим список тем которые относятся к конкретному вопросу public ActionResult AsqQuestion(int id, int page = 1) { QuestionsListViewModel questionsPage = new QuestionsListViewModel { AskQuestions = db.AskQuestions.Where(x => x.ThemaId == id).ToList() .OrderByDescending(x => x.Id) .Skip((page - 1) * PageSize) .Take(PageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = PageSize, TotalItems = db.AskQuestions.Where(x => x.ThemaId == id).Count() } }; //подсчитываем количесто ответов у вопросах List <int> mass = new List <int>(); foreach (var b in db.AskQuestions.Where(x => x.ThemaId == id).ToList()) { mass.Add(db.Talkings.Where(x => x.AskQuestionId == b.Id).Count()); } mass.Reverse(); ViewBag.lenght = mass.Count(); ViewBag.Count = mass; ViewBag.ThemaId = id; ViewBag.ThemePage = db.Themas.Where(x => x.Id == id).FirstOrDefault(); ViewBag.QuestionsCount = db.AskQuestions.Where(x => x.ThemaId == id).Count(); Session["page"] = page; return(View(questionsPage)); }
public QuestionsPage(int?lessonId = null) { viewModel = new QuestionsListViewModel() { LessonId = lessonId }; BindingContext = viewModel; InitializeComponent(); }
public ActionResult MasterList() { var questions = _context.Questions.ToList(); if (questions == null) return HttpNotFound(); var viewModel = new QuestionsListViewModel { QuestionList = questions }; return View(viewModel); }
//выводим список тем которые относятся к конкретному пользователю public ActionResult UserAsqQuestion(int id, int page = 1) { try { var Role = Session["Role"].ToString(); if (Role == "user") { QuestionsListViewModel questionsPage = new QuestionsListViewModel { AskQuestions = db.AskQuestions.Where(x => x.UserId == id).ToList() .OrderByDescending(x => x.Id) .Skip((page - 1) * UPageSize) .Take(UPageSize), PagingInfo = new PagingInfo { CurrentPage = page, ItemsPerPage = UPageSize, TotalItems = db.AskQuestions.Where(x => x.UserId == id).Count() } }; //подсчитываем количесто ответов у вопросах List <int> mass = new List <int>(); foreach (var b in db.AskQuestions.Where(x => x.UserId == id).ToList()) { mass.Add(db.Talkings.Where(x => x.AskQuestionId == b.Id).Count()); } mass.Reverse(); ViewBag.lenght = mass.Count(); ViewBag.Count = mass; ViewBag.ThemaId = id; ViewBag.ThemePage = db.Themas.Where(x => x.Id == id).FirstOrDefault(); ViewBag.QuestionsCount = db.AskQuestions.Where(x => x.ThemaId == id).Count(); Session["user_page"] = page; return(View(questionsPage)); } else { return(RedirectToAction("ErrorAccess", "Error")); } } catch (NullReferenceException) { return(RedirectToAction("ErrorAccess", "Error")); } }
// GET: Questions public ActionResult Index() { QuestionsListViewModel model = new QuestionsListViewModel(); model.Items = webClient.ExecuteGet <IEnumerable <QuestionDto> >(new Models.ApiRequest() { EndPoint = "questions?skip=0&take=10" }) .Select(q => new QuestionsListItem() { Id = q.Id, Text = q.Text }).ToList(); return(View(model)); }
public QuestionsListPage() { InitializeComponent(); BindingContext = viewModel = new QuestionsListViewModel(); }