/// <summary> /// Get Role List from DB /// </summary> /// <returns></returns> public ActionResult GetRoleList(Security_Role_Model qModel) { try { var count = 0; var riSvg = new RoleInfoServices(); var list = riSvg.GetRoleList(qModel, out count); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = new { total = list.Count, rows = list } })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// Get Role List by pager /// </summary> /// <returns></returns> public List <Security_Role_Model> GetRoleList(Security_Role_Model qModel, out int count) { List <Security_Role_Model> list = new List <Security_Role_Model>(); using (PermaisuriCMSEntities db = new PermaisuriCMSEntities()) { var query = db.Security_Role.AsQueryable(); if (!String.IsNullOrEmpty(qModel.Role_Name)) { query = query.Where(s => s.Role_Name.Contains(qModel.Role_Name)); } count = query.Count(); query = query.OrderByDescending(s => s.Created_On).Skip((qModel.page - 1) * qModel.rows).Take(qModel.rows); foreach (var r in query) { list.Add(new Security_Role_Model { Role_GUID = r.Role_GUID, Role_Name = r.Role_Name, Role_Desc = r.Role_Desc }); } return(list); } }
public ActionResult DeleteRole(Security_Role_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } if (model.Role_GUID == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request paramter is null!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; RoleInfoServices uiSvr = new RoleInfoServices(); if (uiSvr.DeleteRole(model)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully delete role" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to delete role" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public bool EditRole(Security_Role_Model model, string curUserAccount) { using (PermaisuriCMSEntities db = new PermaisuriCMSEntities()) { var entity = db.Security_Role.Where(a => a.Role_GUID == model.Role_GUID).FirstOrDefault(); entity.Role_Name = model.Role_Name; entity.Role_Desc = model.Role_Desc; entity.Modified_By = curUserAccount; entity.Modified_On = DateTime.Now; return(db.SaveChanges() > 0); } }
public bool DeleteRole(Security_Role_Model model) { using (PermaisuriCMSEntities db = new PermaisuriCMSEntities()) { var role = new Security_Role { Role_GUID = model.Role_GUID }; db.Set <Security_Role>().Attach(role); db.Security_Role.Remove(role); return(db.SaveChanges() > 0); } }
public bool AddRole(Security_Role_Model model, String curUserAccount) { using (PermaisuriCMSEntities db = new PermaisuriCMSEntities()) { var newRole = new Security_Role { Role_GUID = Guid.NewGuid(), Role_Name = model.Role_Name, Created_By = curUserAccount, Created_On = DateTime.Now, Role_Desc = model.Role_Desc }; db.Security_Role.Add(newRole); return(db.SaveChanges() > 0); } }
public ActionResult AddRole(Security_Role_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } if (model.Role_Name == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Role Name cannot be empty!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; RoleInfoServices iSvr = new RoleInfoServices(); //user is exiting if (iSvr.IsExistUser(model.Role_Name)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "this role is exiting" })); } if (iSvr.AddRole(model, curUserInfo.User_Account)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully add user" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to add new user" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }