public ActionResult Delete(int id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"].ToString().ToUpper(); ViewBag.roleid = Session["RoleID"]; int UserID = Convert.ToInt32(Session["UserId"]); String Username = Session["Username"].ToString(); //Getting all the details of that particular id in PMCheckPoint table configuration_tblpmcheckpoint tblmc = condb.configuration_tblpmcheckpoint.Find(id); using (i_facility_unimechEntities condb = new i_facility_unimechEntities()) { //Getting all the details of that particular id in PMCheckList table var data = condb.configuration_tblpmcheckpoint.Where(m => m.pmcpID == id && m.Isdeleted == 0).ToList(); foreach (var row in data) { //deleting the perticular row of that id in tblPMCheckList table row.Isdeleted = 1; condb.SaveChanges(); } //And deleting the row present in tblPMCheckPoint table } tblmc.Isdeleted = 1; condb.SaveChanges(); TempData["toaster_success"] = "Data Deleted successfully"; return(RedirectToAction("Index")); }
public JsonResult InsertData(int Plant, int shop, int cell, string Value, string CheckList, string Frequency, string TypeOfCheckPoint, string How) { configuration_tblpmcheckpoint tblpc = new configuration_tblpmcheckpoint(); tblpc.CreatedBy = 1; tblpc.CreatedOn = DateTime.Now; tblpc.Isdeleted = 0; tblpc.PlantID = Plant; tblpc.ShopID = shop; tblpc.How = How; tblpc.CellID = cell; tblpc.frequency = Frequency; tblpc.Value = Value; tblpc.CheckList = CheckList; tblpc.TypeofCheckpoint = TypeOfCheckPoint; condb.configuration_tblpmcheckpoint.Add(tblpc); condb.SaveChanges(); return(Json(tblpc.pmcpID, JsonRequestBehavior.AllowGet)); }