public ActionResult DeletePhoto(int personId, int photoId)
        {
            var person = DatabaseSession.Get <Person>(personId);
            var result = PhotosController.Delete(this, photoId);

            if (DatabaseSession.Transaction.IsActive)
            {
                // reassign photo if we just deleted it
                if (person.Photo == null || person.Photo.PhotoId == photoId || person.Photo.IsDefaultNoPic())
                {
                    person.Photo = DatabaseSession.Query <PersonPhoto>()
                                   .Where(x => x.Person == person && x.Photo.PhotoId != photoId)
                                   .Take(1)
                                   .ToList()
                                   .Select(x => x.Photo)
                                   .FirstOrDefault()
                                   ?? DatabaseSession.Load <Photo>(Photo.NoPic);
                }
            }
            if (result != null)
            {
                return(result);
            }
            return(new ViewModelResult(new HttpApiResult
            {
                HttpStatusCode = HttpStatusCode.OK,
                Message = "Photo Deleted",
                RedirectToURL = this.GetURL(c => c.ListPersonPhotos(personId, null)),
            }));
        }
        public ActionResult DeleteTag(int currentPersonId, int photoId, int?personId = null, int?showId = null)
        {
            var result = PhotosController.DeleteTag(this, photoId, personId: personId, showId: showId);

            if (result != null)
            {
                return(result);
            }

            return(new ViewModelResult(new HttpApiResult
            {
                HttpStatusCode = HttpStatusCode.OK,
                Message = "Tag Deleted",
                RedirectToURL = this.GetURL(c => c.ListPersonPhotos(currentPersonId, photoId)),
            }));
        }
        public ActionResult Upload(int personId, PhotosController.UploadPOSTParameters param)
        {
            var validationResult = param.Validate();

            if (validationResult != null)
            {
                return(validationResult);
            }

            var photo = PhotosController.Upload(this, param);

            var personPhoto = new PersonPhoto();

            personPhoto.Person           = DatabaseSession.Load <Person>(personId);
            personPhoto.Photo            = photo;
            personPhoto.InsertedDateTime = DateTime.UtcNow;
            DatabaseSession.Save(personPhoto);

            return(Redirect(Url.GetUrl(ListPersonPhotos, personId, (int?)photo.PhotoId)));
        }
        public ActionResult Upload(int showId, PhotosController.UploadPOSTParameters param)
        {
            var validationResult = param.Validate();

            if (validationResult != null)
            {
                return(validationResult);
            }

            var photo = PhotosController.Upload(this, param);

            var showPhoto = new ShowPhoto();

            showPhoto.Show             = DatabaseSession.Load <Show>(showId);
            showPhoto.Photo            = photo;
            showPhoto.InsertedDateTime = DateTime.UtcNow;
            DatabaseSession.Save(showPhoto);

            return(Redirect(Url.GetUrl(ListShowPhotos, showId, (int?)photo.PhotoId)));
        }
 public ActionResult TagPartial(int currentPersonId, int photoId)
 {
     return(PhotosController.TagPartial(this, photoId, this.GetURL(c => c.AddTag(currentPersonId, photoId, null, null))));
 }
        public ActionResult Upload(int showId, PhotosController.UploadPOSTParameters param)
        {
            var validationResult = param.Validate();
            if (validationResult != null)
            {
                return validationResult;
            }

            var photo = PhotosController.Upload(this, param);

            var showPhoto = new ShowPhoto();
            showPhoto.Show = DatabaseSession.Load<Show>(showId);
            showPhoto.Photo = photo;
            showPhoto.InsertedDateTime = DateTime.UtcNow;
            DatabaseSession.Save(showPhoto);

            return Redirect(Url.GetUrl(ListShowPhotos, showId, (int?)photo.PhotoId));
        }