/// <summary> /// 添加日志 /// </summary> /// <param name="log">日志信息</param> /// <returns>是否添加成功</returns> public bool AddLog(LOG log) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.LOGs.Add(log); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加权限信息 /// </summary> /// <param name="permission">需要添加的权限信息</param> /// <returns>权限是否添加成功</returns> public bool AddPermission(PERMISSION permission) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.PERMISSIONs.Add(permission); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加角色信息 /// </summary> /// <param name="role">需要添加的角色信息</param> /// <returns>角色是否添加成功</returns> public bool AddRole(ROLE role) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.ROLEs.Add(role); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加概略位置 /// </summary> /// <param name="session">概略位置信息</param> /// <returns>是否添加成功</returns> public bool AddGGAHistory(GGAHistory gga) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.GGAHistories.Add(gga); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加菜单信息 /// </summary> /// <param name="menu">需要添加的菜单信息</param> /// <returns>权限是否添加成功</returns> public bool AddMenu(MENU menu) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.MENUs.Add(menu); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加公司信息 /// </summary> /// <param name="company">需要添加的公司信息</param> /// <returns>用户是否添加成功</returns> public bool AddCompany(COMPANY company) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.COMPANies.Add(company); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加会话 /// </summary> /// <param name="session">会话信息</param> /// <returns>是否添加成功</returns> public bool AddSessionHistory(SessionHistory session) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.SessionHistories.Add(session); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 添加单个账号 /// </summary> /// <param name="account">账号信息</param> /// <returns>是否添加成功</returns> public bool AddAccount(ACCOUNT account) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.ACCOUNTs.Add(account); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 通过ID号逻辑删除菜单 /// </summary> /// <param name="id">菜单ID号</param> /// <returns>是否删除成功</returns> public bool SoftDeleteMenuByID(Guid id) { bool result = false; using (var ctx = new NtripProxyDB()) { var menu = ctx.MENUs.FirstOrDefault <MENU>(m => m.ID == id); menu.isDelete = true; result = ctx.SaveChanges() >= 1; } return(result); }
/// <summary> /// 通过ID号逻辑删除用户 /// </summary> /// <param name="id">用户ID号</param> /// <returns>是否删除成功</returns> public bool SoftDeleteUserByID(Guid id) { bool result = false; using (var ctx = new NtripProxyDB()) { var user = ctx.USERs.FirstOrDefault <USER>(u => u.ID == id); user.isDelete = true; result = ctx.SaveChanges() >= 1; } return(result); }
/// <summary> /// 通过ID号逻辑删除公司 /// </summary> /// <param name="id">公司ID号</param> /// <returns>是否删除成功</returns> public bool SoftDeleteCompanyByID(Guid id) { bool result = false; using (var ctx = new NtripProxyDB()) { var company = ctx.COMPANies.FirstOrDefault <COMPANY>(c => c.ID == id); company.isDelete = true; result = ctx.SaveChanges() >= 1; } return(result); }
/// <summary> /// 通过ID号逻辑删除角色 /// </summary> /// <param name="id">角色ID号</param> /// <returns>是否删除成功</returns> public bool SoftDeleteRoleByID(Guid id) { bool result = false; using (var ctx = new NtripProxyDB()) { var role = ctx.ROLEs.FirstOrDefault <ROLE>(r => r.ID == id); role.isDelete = true; result = ctx.SaveChanges() >= 1; } return(result); }
/// <summary> /// 通过ID号逻辑删除账号 /// </summary> /// <param name="id">账号ID号</param> /// <returns>是否删除成功</returns> public bool SoftDeleteAccountByID(Guid id) { bool result = false; using (var ctx = new NtripProxyDB()) { var account = ctx.ACCOUNTs.FirstOrDefault <ACCOUNT>(a => a.ID == id); account.isDelete = true; result = ctx.SaveChanges() >= 1; } return(result); }
/// <summary> /// 通过ID号逻辑删除权限 /// </summary> /// <param name="id">权限ID号</param> /// <returns>是否删除成功</returns> public bool SoftDeletePermissionByID(Guid id) { bool result = false; using (var ctx = new NtripProxyDB()) { var permission = ctx.PERMISSIONs.FirstOrDefault <PERMISSION>(p => p.ID == id); permission.isDelete = true; result = ctx.SaveChanges() >= 1; } return(result); }
/// <summary> /// 添加单个用户 /// </summary> /// <param name="user">需要添加的用户信息</param> /// <returns>用户是否添加成功</returns> public bool AddUser(USER user) { bool result = false; using (var ctx = new NtripProxyDB()) { ctx.USERs.Add(user); //用户密码进行加密操作 user.User_Password = MD5Encrypt(user.User_Password); result = ctx.SaveChanges() == 1; } return(result); }
/// <summary> /// 更新角色相关权限 /// </summary> /// <param name="role">角色信息</param> /// <param name="permissions">权限列表</param> /// <returns>更新权限数量</returns> public int UpdateRolePermissions(ROLE role, List <PERMISSION> permissions) { int result = 0; using (var ctx = new NtripProxyDB()) { var updateItem = ctx.ROLEs.Include("PERMISSIONs").FirstOrDefault <ROLE>(r => r.ID == role.ID); updateItem.PERMISSIONs.Clear(); if (permissions != null && permissions.Count > 0) { foreach (var permission in permissions) { updateItem.PERMISSIONs.Add(ctx.PERMISSIONs.Find(permission.ID)); } result = ctx.SaveChanges(); } else { result = ctx.SaveChanges(); } } return(result); }
/// <summary> /// 更新用户相关角色 /// </summary> /// <param name="user">用户信息</param> /// <param name="roles">角色列表</param> /// <returns>更新角色数量</returns> public int UpdateUserRoles(USER user, List <ROLE> roles) { int result = 0; using (var ctx = new NtripProxyDB()) { var updateItem = ctx.USERs.Include("ROLEs").FirstOrDefault <USER>(u => u.ID == user.ID); updateItem.ROLEs.Clear(); if (roles != null && roles.Count > 0) { foreach (var role in roles) { updateItem.ROLEs.Add(ctx.ROLEs.Find(role.ID)); } result = ctx.SaveChanges(); } else { result = ctx.SaveChanges(); } } return(result); }
/// <summary> /// 更新权限相关菜单 /// </summary> /// <param name="permission">权限信息</param> /// <param name="menus">菜单列表</param> /// <returns>更新菜单数量</returns> public int UpdatePermissionMenus(PERMISSION permission, List <MENU> menus) { int result = 0; using (var ctx = new NtripProxyDB()) { var updateItem = ctx.PERMISSIONs.Include("MENUs").FirstOrDefault <PERMISSION>(p => p.ID == permission.ID); updateItem.MENUs.Clear(); if (menus != null && menus.Count > 0) { foreach (var menu in menus) { updateItem.MENUs.Add(ctx.MENUs.Find(menu.ID)); } result = ctx.SaveChanges(); } else { result = ctx.SaveChanges(); } } return(result); }
/// <summary> /// 更新会话历史基础信息 /// </summary> /// <param name="session">会话信息</param> /// <returns>是否更新成功</returns> public bool UpdateSessionHistory(SessionHistory session) { bool result = false; using (var ctx = new NtripProxyDB()) { if (session.ID != null) { ctx.SessionHistories.Attach(session); ctx.Entry(session).State = EntityState.Modified; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新系统账号资料 /// </summary> /// <param name="accountSYS">需要更新的系统账号</param> /// <returns>是否更新成功</returns> public bool UpdateAccountSYS(ACCOUNTSYS accountSYS) { bool result = false; using (var ctx = new NtripProxyDB()) { if (accountSYS.ID != null) { ctx.ACCOUNTSYS.Attach(accountSYS); ctx.Entry(accountSYS).State = EntityState.Modified; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新菜单基础信息 /// </summary> /// <param name="menu">需要更新的菜单</param> /// <returns>是否更新成功</returns> public bool UpdateMenu(MENU menu) { bool result = false; using (var ctx = new NtripProxyDB()) { if (menu.ID != null) { ctx.MENUs.Attach(menu); ctx.Entry(menu).State = EntityState.Modified; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新角色基础信息 /// </summary> /// <param name="role">需要更新的角色</param> /// <returns>是否更新成功</returns> public bool UpdateRole(ROLE role) { bool result = false; using (var ctx = new NtripProxyDB()) { if (role.ID != null) { ctx.ROLEs.Attach(role); ctx.Entry(role).State = EntityState.Modified; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新权限基础信息 /// </summary> /// <param name="permission">需要更新的权限</param> /// <returns>是否更新成功</returns> public bool UpdatePermission(PERMISSION permission) { bool result = false; using (var ctx = new NtripProxyDB()) { if (permission.ID != null) { ctx.PERMISSIONs.Attach(permission); ctx.Entry(permission).State = EntityState.Modified; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新母公司信息 /// </summary> /// <param name="company">公司信息</param> /// <param name="parentCompany">母公司</param> /// <returns>更新是否成功</returns> public bool UpdateParentCompany(COMPANY company, COMPANY parentCompany) { bool result = false; using (var ctx = new NtripProxyDB()) { if (company.ID != null && parentCompany.ID != null) { company.Company_Chief = parentCompany.ID; ctx.COMPANies.Attach(company); ctx.Entry(company).Property("Company_Chief").IsModified = true; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新账户公司信息 /// </summary> /// <param name="account">账户信息</param> /// <param name="company">公司信息</param> /// <returns>更新是否成功</returns> public bool UpdateAccountCompany(ACCOUNT account, COMPANY company) { bool result = false; using (var ctx = new NtripProxyDB()) { if (account.ID != null && company.ID != null) { account.Account_Company = company.ID; ctx.ACCOUNTs.Attach(account); ctx.Entry(account).Property("Account_Company").IsModified = true; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新公司基础资料 /// </summary> /// <param name="company">需要更新的公司</param> /// <returns>是否更新成功</returns> public bool UpdateCompany(COMPANY company) { bool result = false; using (var ctx = new NtripProxyDB()) { if (company.ID != null) { ctx.COMPANies.Attach(company); ctx.Entry(company).State = EntityState.Modified; //只更新基础信息不更新关联信息 ctx.Entry(company).Property("Company_Chief").IsModified = false; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更改密码 /// </summary> /// <param name="user"></param> /// <returns></returns> public bool ResetUserPassword(USER user) { bool result = false; using (var ctx = new NtripProxyDB()) { if (user.ID != null) { user.User_Password = MD5Encrypt(user.User_Password); ctx.USERs.Attach(user); ctx.Entry(user).State = EntityState.Unchanged; //更改密码信息 ctx.Entry(user).Property("User_Password").IsModified = true; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新账号基础资料 /// </summary> /// <param name="account">需要更新的账号</param> /// <returns>是否更新成功</returns> public bool UpdateAccount(ACCOUNT account) { bool result = false; using (var ctx = new NtripProxyDB()) { if (account.ID != null) { ctx.ACCOUNTs.Attach(account); ctx.Entry(account).State = EntityState.Modified; //只更新基础信息不更新关联信息 ctx.Entry(account).Property("Account_Company").IsModified = false; ctx.Entry(account).Property("Account_AddUser").IsModified = false; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新单个用户基础资料,不更改密码信息 /// </summary> /// <param name="user">需要更新的用户</param> /// <returns>是否更新成功</returns> public bool UpdateUser(USER user) { bool result = false; using (var ctx = new NtripProxyDB()) { if (user.ID != null) { //User_Password 必须有值,不然无法跳过框架检查,所以设置为password值 user.User_Password = "******"; ctx.USERs.Attach(user); ctx.Entry(user).State = EntityState.Modified; //不更改密码信息 ctx.Entry(user).Property("User_Password").IsModified = false; result = ctx.SaveChanges() >= 1; } } return(result); }
/// <summary> /// 更新用户相关公司 /// </summary> /// <param name="user">用户信息</param> /// <param name="company">相关公司</param> /// <returns>更新是否成功</returns> public bool UpdateUserCompany(USER user, COMPANY company) { bool result = false; using (var ctx = new NtripProxyDB()) { if (user.ID != null && company.ID != null) { //User_Password 必须有值,不然无法跳过框架检查,所以设置为password值 user.User_Password = "******"; user.User_Campany = company.ID; ctx.USERs.Attach(user); ctx.Entry(user).Property("User_Campany").IsModified = true; ctx.Entry(user).Property("User_Password").IsModified = false; result = ctx.SaveChanges() >= 1; } } return(result); }