public int CreateAlbum(PhotoAlbum item, IEnumerable<AlbumTag> tags)
        {
            _unitOfWork.Albums.AddAlbum(item, tags);
            _unitOfWork.Save();

            var album = _unitOfWork.Albums
                .Find(a => a.CreationDate == item.CreationDate && a.UserId == item.UserId)
                .First();
            return album.Id;
        }
        public ActionResult CreateAlbum(CreateAlbumViewModel model)
        {
            if (!ModelState.IsValid) return new EmptyResult();

            var album = new PhotoAlbum()
            {
                UserId = CurrentUser.Id,
                Name = model.AlbumName,
                Description = model.AlbumDescription,
                CreationDate = DateTime.Now,
                IsPrivate = model.IsPrivate
            };
            var tags = ParseTagString(model.Tags);
            var information = SaveAlbumInformationInDb(album, tags);

            if (tags != null)
            {
                information.Tags = tags.Select(t => t.TagName).ToArray();
            }
            information.PresentationPhotoUrl = Url.Content("~/Content/Images/default-album-photo.png");

            return Json(information);
        }
 private PhotoAlbumDto SaveAlbumInformationInDb(PhotoAlbum album, IEnumerable<AlbumTag> tags)
 {
     try
     {
         album.Id = DataService.CreateAlbum(album, tags);
         return album.ToPhotoAlbumDto();
     }
     catch (Exception e)
     {
         throw new Exception("Save album failed", e);
     }
 }
 public void UpdateAlbum(PhotoAlbum item)
 {
     _unitOfWork.Albums.Update(item);
     _unitOfWork.Save();
 }