public ActionResult Create(tblshiftmethod tblp) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); #region//ActiveLog Code int UserID = Convert.ToInt32(Session["UserId"]); string CompleteModificationdetail = "New Creation"; Action = "Create"; // ActiveLogStorage Obj = new ActiveLogStorage(); // Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //End #endregion string shiftmethodname = tblp.ShiftMethodName; var doesthisExist = db.tblshiftmethods.Where(m => m.IsDeleted == 0 && m.ShiftMethodName == shiftmethodname).ToList(); if (doesthisExist.Count == 0) { tblp.CreatedBy = UserID; tblp.CreatedOn = DateTime.Now; db.tblshiftmethods.Add(tblp); db.SaveChanges(); } else { TempData["Error"] = "Shift Method Exists."; return(View(tblp)); } return(RedirectToAction("Index")); }
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"]; String Username = Session["Username"].ToString(); int UserID1 = id; int UserID = Convert.ToInt32(Session["UserId"]); tblshiftmethod tblmc = condb.tblshiftmethods.Find(id); var shiftdetailsList = condb.tblshiftdetails.Where(m => m.IsDeleted == 0 && m.ShiftMethodID == id).ToList(); foreach (var shiftdetailsrow in shiftdetailsList) { shiftdetailsrow.IsDeleted = 1; condb.Entry(shiftdetailsrow).State = EntityState.Modified; condb.SaveChanges(); } tblmc.IsDeleted = 1; condb.Entry(tblmc).State = EntityState.Modified; condb.SaveChanges(); TempData["toaster_success"] = "Data Deleted successfully"; return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); tblshiftmethod tblmc = db.tblshiftmethods.Find(id); if (tblmc == null) { return(HttpNotFound()); } return(View(tblmc)); }
// GET: ShiftMethod c public ActionResult Index() { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"].ToString().ToUpper(); ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1()) { ShiftMethodModel pa = new ShiftMethodModel(); tblshiftmethod mp = new tblshiftmethod(); pa.ShiftMethod = mp; pa.ShiftMethodList = condb.tblshiftmethods.Where(m => m.IsDeleted == 0).ToList(); return(View(pa)); } }
public ActionResult Edit(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"]; String Username = Session["Username"].ToString(); using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1()) { tblshiftmethod objshiftmethod2 = condb.tblshiftmethods.Find(id); if (objshiftmethod2 == null) { return(HttpNotFound()); } return(View(objshiftmethod2)); } }
public ActionResult Delete(int id) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID1 = id; //ViewBag.IsConfigMenu = 0; //start Logging int UserID = Convert.ToInt32(Session["UserId"]); string CompleteModificationdetail = "Deleted Role"; Action = "Delete"; // ActiveLogStorage Obj = new ActiveLogStorage(); //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //End tblshiftmethod tblmc = db.tblshiftmethods.Find(id); var shiftdetailsList = db.tblshiftdetails.Where(m => m.IsDeleted == 0 && m.ShiftMethodID == id).ToList(); foreach (var shiftdetailsrow in shiftdetailsList) { shiftdetailsrow.IsDeleted = 1; db.Entry(shiftdetailsrow).State = EntityState.Modified; db.SaveChanges(); } tblmc.IsDeleted = 1; db.Entry(tblmc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(ShiftMethodModel objshiftmethod) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"].ToString().ToUpper(); ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID = Convert.ToInt32(Session["UserID"]); string shiftmethodname = objshiftmethod.ShiftMethod.ShiftMethodName; int shiftmethodId = objshiftmethod.ShiftMethod.ShiftMethodID; using (i_facility_shaktiEntities1 condb = new i_facility_shaktiEntities1()) { var doesthisExist = condb.tblshiftmethods.Where(m => m.IsDeleted == 0 && m.ShiftMethodName == shiftmethodname && m.ShiftMethodID != shiftmethodId).ToList(); if (doesthisExist.Count == 0) { //check if shift method is in use or was used and now its being modified. /* ShiftDetails sd = new ShiftDetails();*/ //Its a class created in seperate file Commented the class int shiftmethodid = Convert.ToInt32(objshiftmethod.ShiftMethod.ShiftMethodID); bool tick = Convert.ToBoolean(0); //sd.IsThisShiftMethodIsInActionOrEnded(shiftmethodid); if (tick) { //tblshiftmethod objsftmethod = new tblshiftmethod(); //objsftmethod.CreatedBy = UserID; //objsftmethod.CreatedOn = DateTime.Now; //objsftmethod.IsDeleted = 0; //objsftmethod.NoOfShifts = objshiftmethod.ShiftMethod.NoOfShifts; //objsftmethod.ShiftMethodDesc = objshiftmethod.ShiftMethod.ShiftMethodDesc; //objsftmethod.ShiftMethodName = objshiftmethod.ShiftMethod.ShiftMethodName; //condb.tblshiftmethod.Add(objsftmethod); //db.SaveChanges(); objshiftmethod.ShiftMethod.ModifiedBy = UserID; objshiftmethod.ShiftMethod.ModifiedOn = DateTime.Now; condb.Entry(objshiftmethod.ShiftMethod).State = EntityState.Modified; condb.SaveChanges(); return(RedirectToAction("Index")); } else { objshiftmethod.ShiftMethod.ModifiedBy = UserID; objshiftmethod.ShiftMethod.ModifiedOn = DateTime.Now; tblshiftmethod sm = condb.tblshiftmethods.Find(objshiftmethod.ShiftMethod.ShiftMethodID); //sm = objshiftmethod.ShiftMethod; sm.ShiftMethodName = objshiftmethod.ShiftMethod.ShiftMethodName; sm.ShiftMethodDesc = objshiftmethod.ShiftMethod.ShiftMethodDesc; sm.NoOfShifts = objshiftmethod.ShiftMethod.NoOfShifts; sm.ModifiedBy = UserID; sm.ModifiedOn = DateTime.Now; condb.Entry(sm).State = EntityState.Modified; condb.SaveChanges(); TempData["toaster_success"] = "Data Updated successfully"; return(RedirectToAction("Index")); } } else { TempData["Error"] = "Shift Method Exists."; return(View(objshiftmethod.ShiftMethod)); } } }
public ActionResult Edit(tblshiftmethod tblmc) { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.Logout = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID = Convert.ToInt32(Session["UserID"]); string shiftmethodname = tblmc.ShiftMethodName; int shiftmethodId = tblmc.ShiftMethodID; var doesthisExist = db.tblshiftmethods.Where(m => m.IsDeleted == 0 && m.ShiftMethodName == shiftmethodname && m.ShiftMethodID != shiftmethodId).ToList(); if (doesthisExist.Count == 0) { #region Active Log Code //tblmachinecategory OldData = db.tblmachinecategories.Find(tblmc.ID); //IEnumerable<string> FullData = ActiveLog.EnumeratePropertyDifferences<tblmachinecategory>(OldData, tblmc); //ICollection<tblmachinecategory> c = FullData as ICollection<tblmachinecategory>; //int Count = c.Count; //if (Count != 0) //{ // string CompleteModificationdetail = null; // for (int i = 0; i < Count; i++) // { // CompleteModificationdetail = CompleteModificationdetail + "-" + FullData.Take(i).ToArray(); // } // Action = "Edit"; // ActiveLogStorage Obj = new ActiveLogStorage(); // Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //} #endregion //End Active Log //check if shift method is in use or was used and now its being modified. ShiftDetails sd = new ShiftDetails(); int shiftmethodid = Convert.ToInt32(tblmc.ShiftMethodID); bool tick = sd.IsThisShiftMethodIsInActionOrEnded(shiftmethodid); if (tick) { tblshiftmethod tsm = new tblshiftmethod(); tsm.CreatedBy = UserID; tsm.CreatedOn = DateTime.Now; tsm.IsDeleted = 0; tsm.NoOfShifts = tblmc.NoOfShifts; tsm.ShiftMethodDesc = tblmc.ShiftMethodDesc; tsm.ShiftMethodName = tblmc.ShiftMethodName; db.tblshiftmethods.Add(tsm); db.SaveChanges(); tblmc.ModifiedBy = UserID; tblmc.ModifiedOn = DateTime.Now; db.Entry(tblmc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else { tblmc.ModifiedBy = UserID; tblmc.ModifiedOn = DateTime.Now; db.Entry(tblmc).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } else { TempData["Error"] = "Shift Method Exists."; return(View(tblmc)); } }