Example #1
0
        public ActionResult SaveAddPerson(SaveEditParameters param)
        {
            if (string.IsNullOrWhiteSpace(param.FirstName) ||
                string.IsNullOrWhiteSpace(param.LastName))
            {
                throw new Exception("Name is required");
            }

            var person = new Person();

            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();
            person.Photo      = DatabaseSession.Load <Photo>(Photo.NoPic);
            // TODO: build in auditing
            person.InsertedDateTime     = DateTime.UtcNow;
            person.LastModifiedDateTime = DateTime.UtcNow;
            DatabaseSession.Save(person);
            DatabaseSession.Flush();

            return(this.RedirectToAction(x => x.PersonDetails(person.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)),
            }));
        }
Example #3
0
        public ActionResult AddCrew(int personId, int showId, string position)
        {
            var entity = new ShowCrew(DatabaseSession.Load <Person>(personId), DatabaseSession.Load <Show>(showId), position);

            DatabaseSession.Save(entity);
            return(new ViewModelResult(new HttpApiResult
            {
                RedirectToURL = this.GetURL(c => c.PersonDetails(personId)),
            }));
        }
Example #4
0
        public ActionResult AddClubPosition(int personId, string position, short year)
        {
            var entity = new PersonClubPosition(DatabaseSession.Load <Person>(personId), position, year);

            DatabaseSession.Save(entity);
            return(new ViewModelResult(new HttpApiResult
            {
                RedirectToURL = this.GetURL(c => c.PersonDetails(personId)),
            }));
        }
Example #5
0
        public ActionResult AddAward(int personId, int awardTypeId, short year, int?showId)
        {
            Show show  = showId.HasValue ? DatabaseSession.Load <Show>(showId.Value) : null;
            var  award = new Award(show, DatabaseSession.Load <Person>(personId), DatabaseSession.Load <AwardType>(awardTypeId), year);

            DatabaseSession.Save(award);
            return(new ViewModelResult(new HttpApiResult
            {
                Message = "Award Added",
                RedirectToURL = this.GetURL(c => c.PersonDetails(personId)),
            }));
        }
Example #6
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 AddAward(int showId, int awardTypeId, short year, int?personId)
        {
            Person person = null;

            if (personId.HasValue)
            {
                person = DatabaseSession.Load <Person>(personId.Value);
            }
            var award = new Award(DatabaseSession.Load <Show>(showId), person, DatabaseSession.Load <AwardType>(awardTypeId), year);

            DatabaseSession.Save(award);

            return(new ViewModelResult(new HttpApiResult
            {
                Message = "Award Added",
                RedirectToURL = this.GetURL(c => c.ShowDetails(showId)),
            }));
        }
        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)));
        }