public bool UpdatePermission(Guid roleId, string resourceIds) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { string[] arrResourceId = resourceIds.Split(','); Permission permission = null; context.Delete <Permission>(obj => obj.RoleId == roleId, false); for (int i = 0; i < arrResourceId.Length; i++) { permission = new Permission(); permission.Id = Guid.NewGuid(); permission.RoleId = roleId; permission.ResourceId = arrResourceId[i]; context.Insert <Permission>(permission, false); } return(context.SaveChanges()); } } catch { throw; } }
public bool AddUserRole(string userIds, string roleIds) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { string[] arrUserId = userIds.Split(','); string[] arrRoleId = roleIds.Split(','); User_Role userRole = null; for (int i = 0; i < arrUserId.Length; i++) { for (int j = 0; j < arrRoleId.Length; j++) { userRole = new User_Role(); userRole.Id = Guid.NewGuid(); userRole.RoleId = new Guid(arrRoleId[j]); userRole.UserId = new Guid(arrUserId[i]); context.Insert <User_Role>(userRole, false); } } return(context.SaveChanges()); } } catch { throw; } }
public bool UpdateProperty(Property property) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.Update <Property>(property, false); return(context.SaveChanges()); } } catch { throw; } }
public bool DeleteProperty(Guid propertyId) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.Delete <Property>(propertyId, false); return(context.SaveChanges()); } } catch { throw; } }
public bool InsertProperty(Property property) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { property.Id = Guid.NewGuid(); context.Insert <Property>(property, false); return(context.SaveChanges()); } } catch { throw; } }
public bool DeleteDistrict(Guid districtId) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.Delete <District>(districtId, false); return(context.SaveChanges()); } } catch { throw; } }
public bool DeleteCity(Guid cityId) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.Delete <City>(cityId, false); context.Delete <District>(obj => obj.CityId == cityId, false); return(context.SaveChanges()); } } catch { throw; } }
public bool DeleteUser(Guid userId) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.Delete <User>(userId, false); context.Delete <User_Role>(obj => obj.UserId == userId, false); return(context.SaveChanges()); } } catch { throw; } }
public bool DeleteRole(Guid roleId) { try { using (IDbContextBase context = DbContextFactory.GetDbContext()) { context.Delete <Role>(roleId, false); context.Delete <User_Role>(obj => obj.RoleId == roleId, false); context.Delete <Permission>(obj => obj.RoleId == roleId, false); return(context.SaveChanges()); } } catch { throw; } }