public IActionResult Post(Answer request)
        {
            try
            {
                using (var db = new AthenaeumContext())
                {
                    db.Add(new Answer()
                    {
                        CreatedDate = DateTime.Now,
                        UpdatedDate = DateTime.Now,
                        Text        = request.Text,
                        UserId      = request.UserId,
                        QuestionId  = request.QuestionId
                    });

                    db.SaveChanges();
                }
                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(new { status = false, message = e.Message }));
            }
        }
示例#2
0
        public IActionResult Post(Question request)
        {
            try
            {
                using (var db = new AthenaeumContext())
                {
                    db.Add(new Question()
                    {
                        CreatedDate   = DateTime.Now,
                        UpdatedDate   = DateTime.Now,
                        MainText      = request.MainText,
                        SecondaryText = request.SecondaryText,
                        UserId        = request.UserId
                    });

                    db.SaveChanges();
                }
                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }