public bool RemoveImageById(Guid imageId) { if (imageId == null) { throw new ArgumentNullException("image id is null"); } foreach (var userId in relationsDAL.GetUsersIdsByImageId(imageId).ToArray()) { relationsDAL.RemoveRelation(userId, imageId); } return(imagesDAL.RemoveImageById(imageId)); }
public bool RemoveUserById(Guid userId) { if (userId == null) { throw new ArgumentNullException("user id is null"); } foreach (var awardId in relationsDAL.GetImagesIdsByUserId(userId).ToArray()) { relationsDAL.RemoveRelation(userId, awardId); } return(usersDAL.RemoveUserById(userId)); }
public bool RemoveImageFromUser(Guid userId, Guid imageId) { if (userId == null || imageId == null) { throw new ArgumentNullException("one of the relation ids are null"); } if (!IsRelationExist(userId, imageId)) { throw new ArgumentException("one of the ids are incorrect, user or award doesn't exist"); } foreach (var user in GetUsersByImage(imageId)) { if (user.Id == userId) { return(relationsDAL.RemoveRelation(userId, imageId)); } } return(false); }