public ActionResult Create(tblrole tblrole) { 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(); // Save was Start Now int UserID = Convert.ToInt32(Session["UserId"]); tblrole.CreatedBy = UserID; tblrole.CreatedOn = System.DateTime.Now; tblrole.IsDeleted = 0; //ActiveLog Code string CompleteModificationdetail = "New Creation"; Action = "Create"; //ActiveLogStorage Obj = new ActiveLogStorage(); //Obj.SaveActiveLog(Action, Controller, Username, UserID, CompleteModificationdetail); //End db.tblroles.Add(tblrole); db.SaveChanges(); 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"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); int UserID1 = id; //ViewBag.IsConfigMenu = 0; tblrole tblrole = db.tblroles.Find(id); tblrole.IsDeleted = 1; tblrole.ModifiedBy = UserID1; tblrole.ModifiedOn = System.DateTime.Now; //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 db.Entry(tblrole).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Roles public ActionResult Index() { if ((Session["UserId"] == null) || (Session["UserId"].ToString() == String.Empty)) { return(RedirectToAction("Login", "Login", null)); } ViewBag.UserName = Session["Username"]; ViewBag.roleid = Session["RoleID"]; String Username = Session["Username"].ToString(); RolesModel Ra = new RolesModel(); tblrole ro = new tblrole(); Ra.Role = ro; Ra.RoleList = db.tblroles.Where(m => m.IsDeleted == 0); return(View(Ra)); }
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(); tblrole tblrole = db.tblroles.Find(id); if (tblrole == null) { return(HttpNotFound()); } return(View(tblrole)); }
public ActionResult Edit(tblrole tblrole) { 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"]); tblrole.ModifiedBy = UserID; tblrole.ModifiedOn = System.DateTime.Now; { if (ModelState.IsValid) { //#region Active Log Code //tblrole OldData = db.tblroles.Find(tblrole.Role_ID); //IEnumerable<string> FullData = ActiveLog.EnumeratePropertyDifferences<tblrole>(OldData, tblrole); //ICollection<tblrole> c = FullData as ICollection<tblrole>; //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 db.Entry(tblrole).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(tblrole)); }
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(); //id = -1; using (i_facility_unimechEntities db = new i_facility_unimechEntities()) { tblrole tblrole = db.tblroles.Find(id); //if (tblrole == null) //{ // //return HttpNotFound(); //} int a = tblrole.Role_ID; return(View(tblrole)); } }
//Update IsDeleted = 1 i.e If IsDeleted=1 then its deleted row 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; using (i_facility_unimechEntities db = new i_facility_unimechEntities()) { tblrole tblrole = db.tblroles.Find(id); tblrole.IsDeleted = 1; tblrole.ModifiedBy = UserID1; tblrole.ModifiedOn = DateTime.Now; db.Entry(tblrole).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index")); }