Example #1
0
 public ActionResult FaqPost(mFaq pFaq)
 {
     if (fUserControl() == 0)
     {
         ViewBag.Message = "شما وارد سایت نشده اید...";
         return(RedirectToAction("LoginForm", "Login"));
     }
     if (!(ModelState.IsValid))
     {
         ViewBag.error = "خطا در  اطلاعات ورودی !";
         return(View(pFaq));
     }
     else
     {
         if (pFaq.faq_id > 0)
         {
             if (c.fUpdateFaq(pFaq))
             {
                 return(RedirectToAction("index"));
             }
             ViewBag.error = "خطا در انجام عملیات  ! ";
         }
         else
         {
             if (c.InsertFaq(pFaq))
             {
                 return(RedirectToAction("index"));
             }
             ViewBag.error = "خطا در انجام عملیات  ! ";
         }
     }
     return(View(pFaq));
 }
Example #2
0
 public bool fUpdateFaq(mFaq pFaq)
 {
     try
     {
         tbl_faq c = new tbl_faq();
         c.faq_id       = pFaq.faq_id;
         c.faq_answer   = pFaq.faq_answer;
         c.faq_exp      = pFaq.faq_exp;
         c.faq_question = pFaq.faq_question;
         Db.tbl_faq.Attach(c);
         Db.Entry(c).State = System.Data.Entity.EntityState.Modified;
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #3
0
        public ActionResult FaqGet(int pId = 0)
        {
            if (fUserControl() == 0)
            {
                ViewBag.Message = "شما وارد سایت نشده اید...";
                return(RedirectToAction("LoginForm", "Login"));
            }
            mFaq vFaq = new mFaq();

            if (pId > 0)
            {
                vFaq.faq_id = pId;
                vFaq        = c.fGetFaq(vFaq);
            }
            else
            {
                vFaq = new mFaq();
            }
            return(View("_Faq", vFaq));
        }
Example #4
0
 public mFaq fGetFaq(mFaq pFaq)
 {
     try
     {
         var vFaq = (from c in Db.tbl_faq
                     where c.faq_id.Equals(pFaq.faq_id)
                     select new mFaq
         {
             faq_id = c.faq_id,
             faq_question = c.faq_question,
             faq_exp = c.faq_exp,
             faq_answer_en = c.faq_question_en,
             faq_question_en = c.faq_question_en,
             faq_answer = c.faq_answer
         }).FirstOrDefault();
         return(vFaq);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Example #5
0
 public bool InsertFaq(mFaq pCat)
 {
     try
     {
         tbl_faq vFaq  = new tbl_faq();
         var     query = from b in Db.tbl_faq
                         orderby b.faq_id descending
                         select b;
         vFaq = query.FirstOrDefault();
         tbl_faq c = new tbl_faq();
         c.faq_answer      = pCat.faq_answer;
         c.faq_exp         = pCat.faq_exp;
         c.faq_question    = pCat.faq_question;
         c.faq_question_en = pCat.faq_question_en;
         c.faq_answer_en   = pCat.faq_answer_en;
         c.faq_id          = vFaq.faq_id + 1;
         Db.tbl_faq.Add(c);
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }