public int CreateAlbum(businessModels.FullAlbum model)
 {
     model.AuthorId = User.Identity.GetUserId();
     model.CreationDate = DateTime.Now;
     model.ModificationDate = DateTime.Now;
     if (ModelState.IsValid)
     {
         //creating photos
         var album = Mapper.Map<Album>(model);
         albumRepository.Create(album);
         return album.Id;
     }
     throw new HttpResponseException(HttpStatusCode.InternalServerError);
 }
        public int UpdateAlbum(businessModels.FullAlbum model)
        {

            if (ModelState.IsValid && albumRepository.IsUserHaveAccessToManage(User.Identity.GetUserId(), model.Id))
            {
                var album = albumRepository.GetById(model.Id);

                album.ModificationDate = DateTime.Now;
                album.Name = model.Name;
                //Album album = albumRepository.GetById(model.Id);
                //album.Name = model.Name;
                //album.Photos = model.Photos;
                //Mapper.CreateMap<businessModels.Category, Category>();
                //album.Categories = (ICollection<Category>)model.Categories.Select(c => Mapper.Map<Category>(c));
                //album.ModificationDate = DateTime.Now;
                //album.Photos = null;
                //model.Categories = null;
                var album1 = Mapper.Map<Album>(model);
                album.Categories = album1.Categories;
                //album.Author = null;
                albumRepository.Update(album);
                return album.Id;
            }

            throw new HttpResponseException(HttpStatusCode.InternalServerError);
        }