Пример #1
0
        public ActionResult DeleteDhammaQA(int QAID)
        {
            DhammaQA deletedDhammaQA = dhammaQARepo.DeleteDhammaQA(QAID);

            if (deletedDhammaQA != null)
            {
                TempData["message"] = "Delete success";
            }
            return(RedirectToAction("DhammaQAManaging"));
        }
        public DhammaQA DeleteDhammaQA(int QAID)
        {
            DhammaQA dbEntry = context.DhammaQAs.Find(QAID);

            if (dbEntry != null)
            {
                context.DhammaQAs.Remove(dbEntry);
                context.SaveChanges();
            }
            return(dbEntry);
        }
Пример #3
0
 public ActionResult SendDhammaQ(DhammaQA dhammaQA)
 {
     if (ModelState.IsValid)
     {
         repository5.SaveDhammaQA(dhammaQA);
         return(RedirectToAction("DhammaQA"));
     }
     else
     {
         // there is something wrong with the data values
         return(View(dhammaQA));
     }
 }
Пример #4
0
 public ActionResult ReplyDhammaQuestion(DhammaQA dhammaQA)
 {
     if (ModelState.IsValid)
     {
         dhammaQARepo.SaveDhammaQA(dhammaQA);
         return(RedirectToAction("DhammaQAManaging"));
     }
     else
     {
         // there is something wrong with the data values
         return(View(dhammaQA));
     }
 }
 public void SaveDhammaQA(DhammaQA dhammaQA)
 {
     if (dhammaQA.QAID == 0)
     {
         context.DhammaQAs.Add(dhammaQA);
     }
     else
     {
         DhammaQA dbEntry = context.DhammaQAs.Find(dhammaQA.QAID);
         if (dbEntry != null)
         {
             dbEntry.Question = dhammaQA.Question;
             dbEntry.Answer   = dhammaQA.Answer;
         }
     }
     context.SaveChanges();
 }
Пример #6
0
        public ViewResult ReplyDhammaQA(int qaID)
        {
            DhammaQA dhammaQA = dhammaQARepo.DhammaQAs.FirstOrDefault(p => p.QAID == qaID);

            return(View(dhammaQA));
        }