Example #1
0
        public void СreateTestQuestion([FromBody] TestQuestion testQuestion)
        {
            tQuestion newQuestion = new tQuestion
            {
                questionText  = testQuestion.Question,
                fkTheme       = testQuestion.ThemeId,
                fkClassNumber = testQuestion.ClassId,
                fkType        = _entities.tQuestionType
                                .Where(qt => qt.name == testQuestion.TypeName)
                                .Select(qt => qt.pk).FirstOrDefault()
            };

            _entities.tQuestion.Add(newQuestion);

            try
            {
                _entities.SaveChanges();
            }
            catch (Exception ex)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound)
                {
                    Content = new StringContent(string.Format("Ошибка при сохранении данных"))
                };
                throw new HttpResponseException(resp);
            }
        }
Example #2
0
        public static tQuestion ToEntity(ViewtQuestion model)
        {
            tQuestion item = new tQuestion();

            item.BeFrom             = model.BeFrom;
            item.ContactInformation = model.ContactInformation;
            item.ID              = model.ID;
            item.IsFAQ           = model.IsFAQ;
            item.QuestionContent = model.QuestionContent;
            item.QuestionTime    = model.QuestionTime;
            item.ReplyContent    = model.ReplyContent;
            item.ReplyTime       = model.ReplyTime;
            item.ReplyUid        = model.ReplyUid;
            item.State           = model.State;
            item.TitleID         = model.TitleID;
            item.Uid             = model.Uid;
            item.UserName        = model.UserName;
            item.IsDelete        = model.IsDelete;
            item.Hot             = model.Hot;
            item.Mark            = model.Mark;
            item.Mark2           = model.Mark2;
            //item.YogaDicItem = model.YogaDicItem;
            //item.YogaUser = model.YogaUser;
            return(item);
        }
Example #3
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            tQuestion = await _context.tQuestion.SingleOrDefaultAsync(m => m.question_id == id);

            if (tQuestion == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #4
0
        //public IActionResult OnGet()
        //{
        //    //ViewData["questions"] = new SelectList(_context.tQuestion, "question_id", "province_name");
        //    return Page();
        //}
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            answers = await _context.tAnswer.Where(a => a.question_id == id).AsNoTracking().ToListAsync();

            question = await _context.tQuestion.SingleOrDefaultAsync(m => m.question_id == id);

            if (question == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Example #5
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            tQuestion = await _context.tQuestion.FindAsync(id);

            if (tQuestion != null)
            {
                _context.tQuestion.Remove(tQuestion);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }