public ActionResult Create(ContactUsDataClass Obj_ContactUsData, string command)
        {
            using (ContactUsDataCtl db = new ContactUsDataCtl())
            {
                if (ModelState.IsValid)
                {
                    db.insert(Obj_ContactUsData);
                    if (command.ToLower().Trim() == "save")
                    {
                        string sesionval = Convert.ToString(Session["CreatePreviousURL"]);
                        if (!string.IsNullOrEmpty(sesionval))
                        {
                            Session.Remove("CreatePreviousURL");
                            return(Redirect(sesionval));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                    else
                    {
                        ModelState.Clear();
                        return(View());
                    }
                }

                return(View(Obj_ContactUsData));
            }
        }
 public ActionResult Details(Int32?Contactusdataid)
 {
     using (ContactUsDataCtl db = new ContactUsDataCtl())
     {
         ContactUsDataClass obj_ContactUsData = db.selectById(Contactusdataid);
         return(View(obj_ContactUsData));
     }
 }
 public ActionResult Edit(Int32?Contactusdataid)
 {
     using (ContactUsDataCtl db = new ContactUsDataCtl())
     {
         ContactUsDataClass obj_ContactUsData = db.selectById(Contactusdataid);
         Session["EditPreviousURL"] = Convert.ToString(ControllerContext.HttpContext.Request.UrlReferrer);
         return(View(obj_ContactUsData));
     }
 }
 public ActionResult SaveRecords(FormCollection model)
 {
     if (ModelState.IsValid)
     {
         using (ContactUsDataCtl db = new ContactUsDataCtl())
         {
             var ContactusdataidArray = model.GetValues("item.Contactusdataid");
             var NameArray            = model.GetValues("item.Name");
             var EmailArray           = model.GetValues("item.Email");
             var MessagesubjectArray  = model.GetValues("item.Messagesubject");
             var DetailedmessageArray = model.GetValues("item.Detailedmessage");
             var AddeddatetimeArray   = model.GetValues("item.Addeddatetime");
             var AddedipArray         = model.GetValues("item.Addedip");
             for (Int32 i = 0; i < ContactusdataidArray.Length; i++)
             {
                 ContactUsDataClass obj_update = db.selectById(Convert.ToInt32(ContactusdataidArray[i]));
                 if (!string.IsNullOrEmpty(Convert.ToString(ContactusdataidArray)))
                 {
                     obj_update.Contactusdataid = Convert.ToInt32(ContactusdataidArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(NameArray)))
                 {
                     obj_update.Name = Convert.ToString(NameArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(EmailArray)))
                 {
                     obj_update.Email = Convert.ToString(EmailArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(MessagesubjectArray)))
                 {
                     obj_update.Messagesubject = Convert.ToString(MessagesubjectArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(DetailedmessageArray)))
                 {
                     obj_update.Detailedmessage = Convert.ToString(DetailedmessageArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(AddeddatetimeArray)))
                 {
                     obj_update.Addeddatetime = Convert.ToDateTime(AddeddatetimeArray[i]);
                 }
                 if (!string.IsNullOrEmpty(Convert.ToString(AddedipArray)))
                 {
                     obj_update.Addedip = Convert.ToString(AddedipArray[i]);
                 }
                 db.update(obj_update);
             }
         }
     }
     return(RedirectToAction("EditTable"));
 }
 public ActionResult Edit(ContactUsDataClass Obj_ContactUsData)
 {
     using (ContactUsDataCtl db = new ContactUsDataCtl())
     {
         if (ModelState.IsValid)
         {
             db.update(Obj_ContactUsData);
             string sesionval = Convert.ToString(Session["EditPreviousURL"]);
             if (!string.IsNullOrEmpty(sesionval))
             {
                 Session.Remove("EditPreviousURL");
                 return(Redirect(sesionval));
             }
             else
             {
                 return(RedirectToAction("Index"));
             }
         }
         return(View(Obj_ContactUsData));
     }
 }