public void UpdateUser(int idUserToUpdate, UserR user) { var oldUser = _db.UserR.Find(idUserToUpdate); oldUser.FirstName = user.FirstName; oldUser.LastName = user.LastName; _db.Entry(user).State = EntityState.Modified; _db.SaveChanges(); }
public void CreateUserPermission(UserR user, Permission permission) { var userPerm = new UserPermission() { Id_User = user.Id, Id_Permission = permission.Id }; _db.UserPermission.Add(userPerm); _db.SaveChanges(); }
public void DeleteUserPermission(UserR user, Permission permission) { var listToRemove = new List <UserPermission>(); _db.UserPermission.ForEachAsync(userPermission => { if (userPermission.Id_User == user.Id && userPermission.Id_Permission == permission.Id) { listToRemove.Add(userPermission); } }); if (listToRemove.Count > 0) { listToRemove.ForEach(x => _db.UserPermission.Remove(x)); } }
public void DeleteUser(UserR user) { _db.UserR.Remove(user); _db.SaveChanges(); }
public void CreateUser(UserR user) { _db.UserR.Add(user); _db.SaveChanges(); }