Ejemplo n.º 1
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)));
        }
Ejemplo n.º 2
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)));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }