Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 public IEnumerable <UserDTO> GetUsersByImage(Guid imageId)
 {
     if (imageId == null)
     {
         throw new ArgumentNullException("image id is null");
     }
     try
     {
         imagesDAL.GetImageById(imageId);
     }
     catch (Exception e)
     {
         throw new ArgumentException("image id is incorrect, image doesn't exist", e);
     }
     return(usersDAL.GetAllUsers().Join(relationsDAL.GetUsersIdsByImageId(imageId),
                                        user => user.Id, userId => userId, (user, userId) => new UserDTO
     {
         Id = userId, FirstName = user.FirstName, DateOfBirth = user.DateOfBirth, Email = user.Email, HashOfPassword = user.HashOfPassword, LastName = user.LastName, Nickname = user.Nickname
     }));
 }