public void InsertPhoto(Photo photo)
 {
     photo.Created = DateTime.Now;
     photo.Updated = DateTime.Now;
     _context.Photos.Add(photo);
     _context.SaveChanges();
 }
 public void InsertPhoto(Photo photo)
 {
     _photoRepository.InsertPhoto(photo);
     if (photo.PhotoFile != null)
     {
         string path = string.Format("{0}{1}", _galleryModuleConfiguration.Get().AlbumStoragePath, photo.AlbumId.ToString());
         _imageUtility.SavePostedFile(photo.PhotoFile.HttpPostedFileBase, path, photo.PhotoFile.Id.ToString(), true);
     }
 }
        public void UpdatePhoto(Photo photo)
        {
            photo.Updated = DateTime.Now;
            _context.Entry(photo).State = EntityState.Modified;
            //var existingResult = _context.Photos.FirstOrDefault(x => x.Id == photo.Id);

            //_context.Entry(existingResult).CurrentValues.SetValues(photo);
            _context.SaveChanges();
        }
 public ActionResult Save(Photo photo)
 {
     ViewBag.AlbumId = _albumService.GetPublishedAlbums().Select(x => new SelectListItem { Text = x.Title, Value = x.Id.ToString() });
     if (photo != null && photo.AlbumId == Guid.Empty)
     {
         ModelState.AddModelError("Error", "Please specify a album");
         return View(photo);
     }
     if (ModelState.IsValid)
     {
         if (photo.IsEdit)
             _photoService.UpdatePhoto(photo);
         else
             _photoService.InsertPhoto(photo);
         return RedirectToAction("Index");
     }
     
     return View(photo);
 }
 public void UpdatePhoto(Photo photo)
 {
     _photoRepository.UpdatePhoto(photo);
 }