public void Create(RolePermissionRepository rolePermissionRepository) { Models.RolePermission newRolePermission = new Models.RolePermission(); newRolePermission.Permissionid = rolePermissionRepository.Permissionid; newRolePermission.Roleid = rolePermissionRepository.Roleid; this.save(newRolePermission); }
private void save(Models.RolePermission RolePermission, bool isUpdate = false) { if (!isUpdate) { this.context.RolePermissions.Add(RolePermission); } this.context.SaveChanges(); }
public void Update(long id, RolePermissionRepository rolePermissionRepository) { Models.RolePermission oldRolePermission = this.rolePermissionQueryRepository.Find(id); if (oldRolePermission == null) { return; } oldRolePermission.Permissionid = rolePermissionRepository.Permissionid; oldRolePermission.Roleid = rolePermissionRepository.Roleid; this.save(oldRolePermission, true); }
public RolePermissionRepository FindById(long id = 0) { Models.RolePermission rolePermission = this.Find(id); if (rolePermission == null) { return(new RolePermissionRepository()); } this.rolePermissionRepository.Id = rolePermission.Id; this.rolePermissionRepository.Permissionid = rolePermission.Permissionid; this.rolePermissionRepository.Roleid = rolePermission.Roleid; this.rolePermissionRepository.MapToRoleRepo(rolePermission.Role); this.rolePermissionRepository.MapToPermissionRepo(rolePermission.Permission); return(this.rolePermissionRepository); }
public RolePermissionRepository FindByRoleAndPermission(long roleid, long permission) { Models.RolePermission rolePermission = this.context.RolePermissions .Where(rolePermission => rolePermission.Roleid == roleid && rolePermission.Permissionid == permission) .FirstOrDefault(); if (rolePermission == null) { return(new RolePermissionRepository()); } this.rolePermissionRepository.Id = rolePermission.Id; this.rolePermissionRepository.Permissionid = rolePermission.Permissionid; this.rolePermissionRepository.Roleid = rolePermission.Roleid; return(this.rolePermissionRepository); }
public void Delete(long id) { Models.RolePermission rolePermission = this.context.RolePermissions.Where(rolePermission => rolePermission.Id == id).FirstOrDefault(); this.context.RolePermissions.Remove(rolePermission); this.context.SaveChanges(); }