示例#1
0
 public ActionResult Post(QuestionNavbar question)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest());
         }
         _context.Add(question);
         return(Ok());
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
示例#2
0
 public ActionResult <QuestionNavbar> Get(int id)
 {
     try
     {
         QuestionNavbar question = _context.GetWithId(id);
         if (question == null)
         {
             return(StatusCode(StatusCodes.Status404NotFound));
         }
         return(Ok(question));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
示例#3
0
        public ActionResult Delete(int id)
        {
            QuestionNavbar dbQuestion = _context.GetWithId(id);

            try
            {
                foreach (Question item in dbQuestion.Questions)
                {
                    item.IsDelete = true;
                }
                _context.Delete(id);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
示例#4
0
        public ActionResult Update(int id, [FromBody] QuestionNavbar questionNavbar)
        {
            try
            {
                QuestionNavbar dbQuestion = _context.GetWithId(id);
                if (dbQuestion == null)
                {
                    return(BadRequest());
                }

                dbQuestion.Title = questionNavbar.Title;

                _context.Update(dbQuestion);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }
 public void Update(QuestionNavbar data)
 {
     _context.Update(data);
 }
 public void Add(QuestionNavbar data)
 {
     _context.Add(data);
 }