public HttpResponseMessage PostAlbum(string sessionKey, AlbumFullModel albumFullModel)
        {
            var responseMsg = this.PerformOperationAndHandleExceptions<HttpResponseMessage>(() =>
            {
                using (var context = new PictureTogetherContext())
                {
                    UsersController.ValidateSessionKey(sessionKey);
                    var currentUser = context.Users.FirstOrDefault(u => u.SessionKey == sessionKey);
                    if (currentUser == null)
                    {
                        throw new ArgumentException("Expired or invalid sessionKey. Please try to relog with your account.");
                    }

                    var newAlbum = new Album
                    {
                        Name = albumFullModel.Name,
                        Latitude = albumFullModel.Latitude,
                        Longitude = albumFullModel.Longitude,
                        Users =
                        {
                            currentUser
                        }
                    };

                    currentUser.Albums.Add(newAlbum);
                    context.Albums.Add(newAlbum);
                    context.SaveChanges();

                    var albumModel = new AlbumModel
                    {
                        Id = newAlbum.Id,
                        Name = newAlbum.Name
                    };

                    var response = this.Request.CreateResponse(HttpStatusCode.Created, albumModel);
                    return response;
                }
            });

            return responseMsg;
        }
        public HttpResponseMessage PutAlbum(string sessionKey, ShareCodeModel shareCodeModel)
        {
            var responseMsg = this.PerformOperationAndHandleExceptions<HttpResponseMessage>(() =>
            {
                using (var context = new PictureTogetherContext())
                {
                    UsersController.ValidateSessionKey(sessionKey);
                    var currentUser = context.Users.FirstOrDefault(u => u.SessionKey == sessionKey);
                    if (currentUser == null)
                    {
                        throw new ArgumentException("Expired or invalid sessionKey. Please try to relog with your account.");
                    }

                    var album = context.Albums.Find(shareCodeModel.AlbumId);
                    if (album == null)
                    {
                        throw new ArgumentException("Invalid share code.");
                    }

                    var sharingUser = context.Users.FirstOrDefault(u => u.Username == shareCodeModel.Username);
                    if (sharingUser == null)
                    {
                        throw new ArgumentException("Invalid share code.");
                    }

                    var sharingUserAlbum = sharingUser.Albums.FirstOrDefault(a => a.Id == album.Id);
                    if (sharingUserAlbum == null)
                    {
                        throw new ArgumentException("Invalid share code.");
                    }

                    var currentUserAlbum = currentUser.Albums.FirstOrDefault(a => a.Id == album.Id);
                    if (currentUserAlbum != null)
                    {
                        throw new ArgumentException("This album is already shared with you.");
                    }

                    currentUser.Albums.Add(album);
                    album.Users.Add(currentUser);
                    context.SaveChanges();

                    var albumModel = new AlbumModel
                    {
                        Id = album.Id,
                        Name = album.Name
                    };
                    var response = this.Request.CreateResponse(HttpStatusCode.OK, albumModel);
                    return response;
                }
            });

            return responseMsg;
        }