Пример #1
0
 public bool commitInsert(faq qa)
 {
     using (obj)
     {
         //inserting into database
         obj.faqs.InsertOnSubmit(qa);
         obj.SubmitChanges();
         return true;
     }
 }
 public ActionResult Delete(int id, faq qa)
 {
     //deletes an faq based on id
     try
     {
         obj.commitDelete(id);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
 partial void Deletefaq(faq instance);
 partial void Updatefaq(faq instance);
 partial void Insertfaq(faq instance);
 public ActionResult Insert(faq qa)
 {
     //Inserting into the table
     if (ModelState.IsValid)
     {
         try
         {
             obj.commitInsert(qa);
             return RedirectToAction("Index");
         }
         catch
         {
             return View();
         }
     }
     return View();
 }
 public ActionResult Update(int id, faq qa)
 {
     //updating a faq based on id
     if (ModelState.IsValid)
     {
         try
         {
             obj.commitUpdate(id, qa.question, qa.answer);
             return RedirectToAction("Details/" + id);
         }
         catch
         {
             return View();
         }
     }
     return View();
 }