public ActionResult POSTEditUser(int userId, UserAccountViewModel postModel)
        {
            var user = DatabaseSession.Get <UserAccount>(userId);

            if (user == null)
            {
                return(new HttpNotFoundResult());
            }

            if (this.User.IsInRole(RoleNames.Admin) && ((ClaimsPrincipal)this.User).GetUserAccountId() == userId)
            {
                // do not allow admin to remove self from admin role
                postModel.IsAdmin = true;
            }

            user.IsContributor = postModel.IsContributor;
            user.IsArchivist   = postModel.IsArchivist;
            user.IsAdmin       = postModel.IsAdmin;

            if (Request.IsAjaxRequest())
            {
                return(Json("OK"));
            }

            return(this.RedirectToAction(c => c.List()));
        }
Esempio n. 2
0
        public ActionResult EditAwardType(int awardTypeId)
        {
            var awardType = DatabaseSession.Get <AwardType>(awardTypeId);
            var viewModel = new AwardTypeViewModel(awardType, this.Url);

            return(PartialView(viewModel));
        }
        public ActionResult EditUser(int userId)
        {
            var user          = DatabaseSession.Get <UserAccount>(userId);
            var userViewModel = new UserAccountViewModel(user, this.Url);

            return(PartialView(userViewModel));
        }
        public ActionResult GetPhotoDetail(int id)
        {
            var photos = DatabaseSession
                         .Query <Photo>()
                         .Select(x => new PhotoItemDto
            {
                PhotoId          = x.PhotoId,
                InsertedDateTime = x.InsertedDateTime,
            })
                         .ToList().OrderBy(x => x.PhotoId).ToList();


            var index      = photos.IndexOf(photos.Single(x => x.PhotoId == id));
            var previousId = index > 0 ? photos[index - 1].PhotoId : (int?)null;
            var nextId     = index < photos.Count - 1 ? photos[index + 1].PhotoId : (int?)null;

            var viewModel = new PhotoDetailViewModel();

            viewModel.PhotoUploadLinkURL   = "";
            viewModel.PreviousPhotoLinkURL = this.GetURL(c => c.GetPhotoDetail(id));
            viewModel.NextPhotoLinkURL     = this.GetURL(c => c.GetPhotoDetail(id));
            if (previousId.HasValue)
            {
                viewModel.HasPreviousPhotoLinkURL = true;
                viewModel.PreviousPhotoLinkURL    = this.GetURL(c => c.GetPhotoDetail(previousId.Value));
            }
            if (nextId.HasValue)
            {
                viewModel.HasNextPhotoLinkURL = true;
                viewModel.NextPhotoLinkURL    = this.GetURL(c => c.GetPhotoDetail(nextId.Value));
            }

            viewModel.PhotoViewModel = new PhotoViewModel(DatabaseSession.Get <Photo>(id), "", this);
            return(View(viewModel));
        }
        public ActionResult DeleteAward(int awardId)
        {
            var award = DatabaseSession.Get <Award>(awardId);

            DatabaseSession.Delete(award);
            return(this.RedirectToAction(x => x.ByYear(award.Year)));
        }
Esempio n. 6
0
        public ActionResult EditPerson(int personId)
        {
            if (!Request.IsAjaxRequest())
            {
                return(this.RedirectToAction(x => x.PersonDetails(personId)));
            }

            var person = DatabaseSession.Get <Person>(personId);
            var photos = DatabaseSession.Query <PersonPhoto>().Where(x => x.Person == person).Fetch(x => x.Photo).ToList();

            var viewModel = new EditPersonViewModel();

            viewModel.POSTUrl        = Url.Action("SaveEdit");
            viewModel.PersonId       = personId;
            viewModel.FirstName      = person.FirstName;
            viewModel.LastName       = person.LastName;
            viewModel.MiddleName     = person.MiddleName;
            viewModel.Honorific      = person.Honorific;
            viewModel.Suffix         = person.Suffix;
            viewModel.Nickname       = person.Nickname;
            viewModel.Biography      = person.Biography;
            viewModel.DefaultPhotoId = person.Photo.PhotoId;
            viewModel.Photos         = photos.OrderBy(x => x.Photo.InsertedDateTime).ThenBy(x => x.Photo.PhotoId).Select(x => new EditPersonViewModel.Photo
            {
                PhotoItemId       = x.Photo.PhotoId,
                PhotoTinyURL      = x.Photo.GetTinyFileURL(),
                PhotoThumbnailURL = x.Photo.GetThumbnailFileURL(),
            }).ToList();

            return(PartialView(viewModel));
        }
Esempio n. 7
0
        public ActionResult SaveEdit(int personId, SaveEditParameters param)
        {
            if (string.IsNullOrWhiteSpace(param.FirstName) ||
                string.IsNullOrWhiteSpace(param.LastName))
            {
                throw new Exception("Name is required");
            }

            var person = DatabaseSession.Get <Person>(personId);

            person.FirstName  = (param.FirstName ?? string.Empty).Trim();
            person.LastName   = (param.LastName ?? string.Empty).Trim();
            person.MiddleName = (param.MiddleName ?? string.Empty).Trim();
            person.Honorific  = (param.Honorific ?? string.Empty).Trim();
            person.Suffix     = (param.Suffix ?? string.Empty).Trim();
            person.Nickname   = (param.Nickname ?? string.Empty).Trim();
            person.Biography  = (param.Biography ?? string.Empty).Trim();
            if (DatabaseSession.IsDirtyEntity(person))
            {
                // TODO: build in auditing
                person.LastModifiedDateTime = DateTime.UtcNow;
            }

            return(this.RedirectToAction(x => x.PersonDetails(personId)));
        }
        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 DeleteCast(int showId, int showCastId)
        {
            var entity = DatabaseSession.Get <ShowCast>(showCastId);

            DatabaseSession.Delete(entity);
            return(new ViewModelResult(new HttpApiResult
            {
                RedirectToURL = this.GetURL(c => c.ShowDetails(showId)),
            }));
        }
        public ActionResult GetPhotoThumbnail(int id)
        {
            var photo = DatabaseSession.Get <Photo>(id);

            if (photo == null)
            {
                return(new HttpNotFoundResult());
            }
            return(new RedirectResult(photo.GetThumbnailFileURL()));
        }
Esempio n. 11
0
        public ActionResult DeleteCrew(int personId, int showCrewId)
        {
            var entity = DatabaseSession.Get <ShowCrew>(showCrewId);

            DatabaseSession.Delete(entity);
            return(new ViewModelResult(new HttpApiResult
            {
                RedirectToURL = this.GetURL(c => c.PersonDetails(personId)),
            }));
        }
Esempio n. 12
0
        public ActionResult DeleteAward(int personId, int awardId)
        {
            var award = DatabaseSession.Get <Award>(awardId);

            DatabaseSession.Delete(award);
            return(new ViewModelResult(new HttpApiResult
            {
                Message = "Award Deleted",
                RedirectToURL = this.GetURL(c => c.PersonDetails(personId)),
            }));
        }
Esempio n. 13
0
        public ActionResult AddAward(int personId)
        {
            var person     = DatabaseSession.Get <Person>(personId);
            var awardTypes = DatabaseSession.Query <AwardType>().ToList();
            var shows      = DatabaseSession.Query <Show>().ToList();
            var viewModel  = new AddAwardViewModel(awardTypes, shows)
            {
                POSTUrl = this.GetURL(x => x.AddAward(personId)),
            };

            return(new ViewModelResult(viewModel));
        }
Esempio n. 14
0
        public ActionResult AddAward(int showId)
        {
            var show       = DatabaseSession.Get <Show>(showId);
            var awardTypes = DatabaseSession.Query <AwardType>().ToList();
            var people     = DatabaseSession.Query <Person>().ToList();
            var viewModel  = new AddAwardViewModel(awardTypes, people, show.Year)
            {
                POSTUrl = this.GetURL(c => c.AddAward(showId)),
            };

            return(new ViewModelResult(viewModel));
        }
Esempio n. 15
0
        public ActionResult ChangeDefaultPhoto(int personId, int photoId)
        {
            var person = DatabaseSession.Get <Person>(personId);

            person.Photo = DatabaseSession.Load <Photo>(photoId);
            if (DatabaseSession.IsDirtyEntity(person))
            {
                // TODO: build in auditing
                person.LastModifiedDateTime = DateTime.UtcNow;
            }

            return(this.RedirectToAction(x => x.PersonDetails(personId)));
        }
        public ActionResult Upload(int showId)
        {
            var show = DatabaseSession.Get <Show>(showId);

            var viewModel = new UploadViewModel();

            viewModel.ParentName       = show.DisplayTitleWithYear;
            viewModel.ParentLinkURL    = this.GetURL <ShowController>(c => c.ShowDetails(showId));
            viewModel.PhotoCount       = DatabaseSession.Query <ShowPhoto>().Where(x => x.Show == show).Count();
            viewModel.PhotoListLinkURL = Url.GetUrl(ListShowPhotos, showId, (int?)null);
            viewModel.UploadFormURL    = Url.GetUrl(Upload, showId, (PhotosController.UploadPOSTParameters)null);

            return(new ViewModelResult(viewModel));
        }
        public ActionResult Upload(int personId)
        {
            var person = DatabaseSession.Get <Person>(personId);

            var viewModel = new UploadViewModel();

            viewModel.ParentName       = person.Fullname;
            viewModel.ParentLinkURL    = this.GetURL <PersonController>(c => c.PersonDetails(personId));
            viewModel.PhotoCount       = DatabaseSession.Query <PersonPhoto>().Where(x => x.Person == person).Count();
            viewModel.PhotoListLinkURL = Url.GetUrl(ListPersonPhotos, personId, (int?)null);
            viewModel.UploadFormURL    = Url.GetUrl(Upload, personId, (PhotosController.UploadPOSTParameters)null);

            return(new ViewModelResult(viewModel));
        }
Esempio n. 18
0
        public ActionResult AddClubPosition(int personId)
        {
            if (!Request.IsAjaxRequest())
            {
                return(this.RedirectToAction(x => x.PersonDetails(personId)));
            }
            var person    = DatabaseSession.Get <Person>(personId);
            var positions = DatabaseSession.Query <PersonClubPosition>().Select(x => x.Position).Distinct().ToList();
            var viewModel = new AddClubPositionViewModel(positions)
            {
                POSTUrl = this.GetURL(x => x.AddClubPosition(personId)),
            };

            return(new ViewModelResult(viewModel));
        }
Esempio n. 19
0
        public ActionResult AddCast(int personId)
        {
            if (!Request.IsAjaxRequest())
            {
                return(this.RedirectToAction(x => x.PersonDetails(personId)));
            }

            var person    = DatabaseSession.Get <Person>(personId);
            var shows     = DatabaseSession.Query <Show>().ToList();
            var viewModel = new AddCastViewModel(shows)
            {
                POSTUrl = this.GetURL(x => x.AddCast(personId)),
            };

            return(new ViewModelResult(viewModel));
        }
        public ActionResult ListPersonPhotos(int personId, int?photoId = null)
        {
            var person = DatabaseSession.Get <Person>(personId);

            if (photoId == null && person.Photo != null && !person.Photo.IsDefaultNoPic())
            {
                return(Redirect(this.GetURL(c => c.ListPersonPhotos(personId, person.Photo.PhotoId))));
            }

            var photos = DatabaseSession.Query <PersonPhoto>()
                         .Where(x => x.Person == person).Fetch(x => x.Photo)
                         .ToList();

            if (photoId == null && photos.Any())
            {
                return(Redirect(this.GetURL(c => c.ListPersonPhotos(personId, photos.First().Photo.PhotoId))));
            }

            var viewModel = new PhotoListViewModel();

            viewModel.ParentName             = person.Fullname;
            viewModel.ParentLinkURL          = this.GetURL <PersonController>(c => c.PersonDetails(personId));
            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = Url.GetUrl(Upload, personId);
            viewModel.Photos = photos
                               .OrderBy(x => x.Photo.InsertedDateTime).ThenBy(x => x.Photo.PhotoId)
                               .Select(x => new PhotoListViewModel.Photo
            {
                PhotoLinkURL      = this.GetURL(c => c.ListPersonPhotos(personId, x.Photo.PhotoId)),
                PhotoThumbnailURL = x.Photo.GetThumbnailFileURL(),
            }).ToList();

            if (photoId.HasValue)
            {
                var photo = photos.SingleOrDefault(x => x.Photo.PhotoId == photoId.Value);
                if (photo == null)
                {
                    return(Redirect(this.GetURL(c => c.ListPersonPhotos(personId, null))));
                }
                viewModel.CurrentPhotoViewModel = new PhotoViewModel(photo.Photo, this.GetURL(c => c.ListPersonPhotos(personId, photoId.Value)), this);
            }

            return(new ViewModelResult(viewModel));
        }
        public ActionResult ListShowPhotos(int showId, int?photoId = null)
        {
            var show = DatabaseSession.Get <Show>(showId);

            if (photoId == null && show.Photo != null && !show.Photo.IsDefaultNoPic())
            {
                return(Redirect(this.GetURL(c => c.ListShowPhotos(showId, show.Photo.PhotoId))));
            }

            var photos = DatabaseSession.Query <ShowPhoto>()
                         .Where(x => x.Show == show).Fetch(x => x.Photo)
                         .ToList();

            if (photoId == null && photos.Any())
            {
                return(Redirect(this.GetURL(c => c.ListShowPhotos(showId, photos.First().Photo.PhotoId))));
            }

            var viewModel = new PhotoListViewModel();

            viewModel.ParentName             = show.DisplayTitleWithYear;
            viewModel.ParentLinkURL          = this.GetURL <ShowController>(c => c.ShowDetails(showId));
            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = Url.GetUrl(Upload, showId);
            viewModel.Photos = photos
                               .OrderBy(x => x.Photo.InsertedDateTime).ThenBy(x => x.Photo.PhotoId)
                               .Select(x => new PhotoListViewModel.Photo
            {
                PhotoLinkURL      = this.GetURL(c => c.ListShowPhotos(showId, x.Photo.PhotoId)),
                PhotoThumbnailURL = x.Photo.GetThumbnailFileURL(),
            }).ToList();

            if (photoId.HasValue)
            {
                var photo = photos.SingleOrDefault(x => x.Photo.PhotoId == photoId.Value);
                if (photo == null)
                {
                    return(Redirect(this.GetURL(c => c.ListShowPhotos(showId, null))));
                }
                viewModel.CurrentPhotoViewModel = new PhotoViewModel(photo.Photo, this.GetURL(c => c.ListShowPhotos(showId, photoId.Value)), this);
            }

            return(View(viewModel));
        }
Esempio n. 22
0
        public ActionResult POSTEditEditAwardType(int awardTypeId, AwardTypeViewModel postModel)
        {
            var awardType = DatabaseSession.Get <AwardType>(awardTypeId);

            if (awardType == null)
            {
                return(new HttpNotFoundResult());
            }

            if (string.IsNullOrWhiteSpace(postModel.Name))
            {
                return(new HttpBadRequestResult("Name Must Not Be Null"));
            }

            awardType.Name = postModel.Name;

            if (Request.IsAjaxRequest())
            {
                return(Json("OK"));
            }

            return(this.RedirectToAction(c => c.Admin()));
        }
Esempio n. 23
0
        public ActionResult ShowDetails(int showId)
        {
            var orderedShows   = DatabaseSession.Query <Show>().ToList().OrderBy(x => x).ToList();
            var index          = orderedShows.IndexOf(orderedShows.Single(x => x.ShowId == showId));
            var previousShowId = index > 0 ? orderedShows[index - 1].ShowId : (int?)null;
            var nextShowId     = index < orderedShows.Count - 1 ? orderedShows[index + 1].ShowId : (int?)null;

            var show = DatabaseSession.Get <Show>(showId);

            var crew   = DatabaseSession.Query <ShowCrew>().Where(x => x.Show == show).Fetch(x => x.Person).ToList();
            var cast   = DatabaseSession.Query <ShowCast>().Where(x => x.Show == show).Fetch(x => x.Person).ToList();
            var awards = DatabaseSession.Query <Award>().Where(x => x.Show == show).Fetch(x => x.Person).Fetch(x => x.AwardType).ToList();

            var relatedPhotos = DatabaseSession.Query <ShowPhoto>().Where(x => x.Show == show).Fetch(x => x.Photo).ToList();

            var otherPerformances = DatabaseSession.Query <Show>()
                                    .Where(x => x.Title == show.Title &&
                                           x.ShowId != show.ShowId)
                                    .ToList();

            var viewModel = new ShowDetailsViewModel();

            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = this.GetURL <ShowPhotosController>(c => c.Upload(showId));
            viewModel.PhotoLinkURL           = this.GetURL <ShowPhotosController>(c => c.ListShowPhotos(showId, show.Photo.PhotoId));
            viewModel.PhotoThumbnailURL      = show.Photo.GetThumbnailFileURL();
            viewModel.PhotoListLinkURL       = this.GetURL <ShowPhotosController>(c => c.ListShowPhotos(showId, null));

            viewModel.Title               = show.DisplayTitle;
            viewModel.Author              = show.Author;
            viewModel.Quarter             = show.Quarter;
            viewModel.Year                = show.Year;
            viewModel.FunFacts            = show.FunFacts;
            viewModel.Pictures            = show.Pictures;
            viewModel.Toaster             = show.Toaster;
            viewModel.PreviousShowLinkURL = previousShowId.HasValue ? this.GetURL(c => c.ShowDetails(previousShowId.Value)) : "";
            viewModel.NextShowLinkURL     = nextShowId.HasValue ? this.GetURL(c => c.ShowDetails(nextShowId.Value)) : "";

            viewModel.OtherPerformances = new OtherPerformancesTableViewModel(this.Url, otherPerformances);

            viewModel.AwardsTable = new AwardsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteAward(showId, id))
                , awards)
            {
                CanEdit    = this.ControllerContext.CanEditShow(show),
                AddItemURL = this.GetURL(c => c.AddAward(showId)),
            };

            viewModel.CastRolesTable = new CastRolesTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteCast(showId, id))
                , cast)
            {
                CanEdit    = this.ControllerContext.CanEditShow(show),
                AddItemURL = this.GetURL(c => c.AddCast(showId)),
            };

            viewModel.CrewPositionsTable = new CrewPositionsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteCrew(showId, id))
                , crew)
            {
                CanEdit    = this.ControllerContext.CanEditShow(show),
                AddItemURL = this.GetURL(c => c.AddCrew(showId)),
            };

            viewModel.PhotoCount = relatedPhotos.Count;
            viewModel.NewPhotos  = relatedPhotos
                                   .OrderByDescending(x => x.InsertedDateTime)
                                   .Where(x => x.Photo.PhotoId != show.Photo.PhotoId)
                                   .Select(x => new ShowDetailsViewModel.NewPhotoViewModel
            {
                PhotoLinkURL = this.GetURL <ShowPhotosController>(c => c.ListShowPhotos(showId, x.Photo.PhotoId)),
                PhotoTinyURL = x.Photo.GetTinyFileURL(),
            })
                                   .Take(4)
                                   .ToList();

            return(View(viewModel));
        }
Esempio n. 24
0
        public ActionResult PersonDetails(int personId)
        {
            var person        = DatabaseSession.Get <Person>(personId);
            var clubPositions = DatabaseSession.Query <PersonClubPosition>().Where(x => x.Person == person).ToList();
            var crew          = DatabaseSession.Query <ShowCrew>().Where(x => x.Person == person).Fetch(x => x.Show).ToList();
            var cast          = DatabaseSession.Query <ShowCast>().Where(x => x.Person == person).Fetch(x => x.Show).ToList();
            var awards        = DatabaseSession.Query <Award>().Where(x => x.Person == person).Fetch(x => x.Show).Fetch(x => x.AwardType).ToList();
            var photos        = DatabaseSession.Query <PersonPhoto>().Where(x => x.Person == person).Fetch(x => x.Photo).ToList();

            var viewModel = new PersonDetailsViewModel();

            viewModel.EditLinkURL            = this.GetURL(c => c.EditPerson(personId));
            viewModel.ShowPhotoUploadControl = User.IsInRole(RoleNames.Contributor) || User.IsInRole(RoleNames.Archivist);
            viewModel.PhotoUploadLinkURL     = this.GetURL <PersonPhotosController>(c => c.Upload(personId));
            viewModel.PhotoLinkURL           = this.GetURL <PersonPhotosController>(c => c.ListPersonPhotos(personId, person.Photo.PhotoId));
            viewModel.PhotoThumbnailURL      = person.Photo.GetThumbnailFileURL();
            viewModel.PhotoListLinkURL       = this.GetURL <PersonPhotosController>(c => c.ListPersonPhotos(personId, null));

            viewModel.FullName  = person.Fullname;
            viewModel.Biography = person.Biography;

            viewModel.AwardsTable = new AwardsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteAward(personId, id))
                , awards)
            {
                CanEdit    = this.ControllerContext.CanEditPerson(person),
                AddItemURL = this.GetURL(c => c.AddAward(personId)),
            };

            viewModel.ClubPositionsTable = new ClubPositionsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteClubPosition(personId, id))
                , clubPositions)
            {
                CanEdit    = this.ControllerContext.CanEditPerson(person),
                AddItemURL = this.GetURL(c => c.AddClubPosition(personId)),
            };

            viewModel.CastRolesTable = new Views.Show.CastRolesTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteCast(personId, id))
                , cast)
            {
                CanEdit    = this.ControllerContext.CanEditPerson(person),
                AddItemURL = this.GetURL(c => c.AddCast(personId)),
            };

            viewModel.CrewPositionsTable = new Views.Show.CrewPositionsTableViewModel(
                this.Url
                , id => this.GetURL(c => c.DeleteCrew(personId, id))
                , crew)
            {
                CanEdit    = this.ControllerContext.CanEditPerson(person),
                AddItemURL = this.GetURL(c => c.AddCrew(personId)),
            };

            viewModel.PhotoCount = photos.Count;
            viewModel.NewPhotos  = photos
                                   .OrderByDescending(x => x.InsertedDateTime)
                                   .Where(x => x.Photo.PhotoId != person.Photo.PhotoId)
                                   .Select(x => new PersonDetailsViewModel.NewPhotosViewModel
            {
                PhotoLinkURL = this.GetURL <PersonPhotosController>(c => c.ListPersonPhotos(personId, x.Photo.PhotoId)),
                PhotoTinyURL = x.Photo.GetTinyFileURL(),
            })
                                   .Take(4)
                                   .ToList();

            return(View(viewModel));
        }