Exemplo n.º 1
0
        //выводим список тем которые относятся к конкретному вопросу
        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));
        }
Exemplo n.º 2
0
 public QuestionsPage(int?lessonId = null)
 {
     viewModel = new QuestionsListViewModel()
     {
         LessonId = lessonId
     };
     BindingContext = viewModel;
     InitializeComponent();
 }
Exemplo n.º 3
0
        public ActionResult MasterList()
        {
            var questions = _context.Questions.ToList();
            if (questions == null)
                return HttpNotFound();
            var viewModel = new QuestionsListViewModel
            {
                QuestionList = questions
            };

            return View(viewModel);
        }
Exemplo n.º 4
0
        //выводим список тем которые относятся к конкретному пользователю
        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"));
            }
        }
Exemplo n.º 5
0
        // 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();
        }