Пример #1
0
        public static President GetGroverClevelandAsPresident()
        {
            var info = new President();

            info.FirstName = "Grover";
            info.LastName  = "Cleveland";

            info.ImageFilename = "grover.jpg";

            info.AddTerm(
                "President",
                new DateTime(1885, 3, 4),
                new DateTime(1889, 3, 4),
                22);

            info.AddTerm(
                "President",
                new DateTime(1893, 3, 4),
                new DateTime(1897, 3, 4),
                24);

            info.BirthDate = new DateTime(1837, 3, 18);
            info.DeathDate = new DateTime(1908, 6, 24);

            info.BirthCity  = "Caldwell";
            info.BirthState = "New Jersey";

            info.DeathCity  = "Princeton";
            info.DeathState = "New Jersey";

            return(info);
        }
Пример #2
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new BadRequestResult());
            }

            President president;

            if (id.Value == ID_FOR_CREATE_NEW_PRESIDENT)
            {
                // create new
                president = new President();
                president.AddTerm(PresidentsConstants.President,
                                  default(DateTime),
                                  default(DateTime), 0);
            }
            else
            {
                president = _Service.GetPresidentById(id.Value);
            }

            if (president == null)
            {
                return(NotFound());
            }

            return(View(president));
        }
Пример #3
0
        private President GetPresidentFromXml(XElement fromValue)
        {
            President toValue = new President();

            toValue.BirthCity  = fromValue.AttributeValue("birthcity");
            toValue.BirthState = fromValue.AttributeValue("birthstate");
            toValue.BirthDate  = SafeToDateTime(fromValue.AttributeValue("birthdate"));

            toValue.DeathCity  = fromValue.AttributeValue("deathcity");
            toValue.DeathState = fromValue.AttributeValue("deathstate");
            toValue.DeathDate  = SafeToDateTime(fromValue.AttributeValue("deathdate"));

            toValue.FirstName = fromValue.AttributeValue("firstname");
            toValue.LastName  = fromValue.AttributeValue("lastname");

            toValue.ImageFilename = fromValue.AttributeValue("image-filename");

            toValue.AddTerm(
                "President",
                SafeToDateTime(fromValue.AttributeValue("start")),
                SafeToDateTime(fromValue.AttributeValue("end")),
                SafeToInt32(fromValue.AttributeValue("id"))
                );

            return(toValue);
        }
Пример #4
0
        public static President GetThomasJeffersonAsPresident()
        {
            var info = new President();

            info.FirstName = "Thomas";
            info.LastName  = "Jefferson";

            info.ImageFilename = "tommy-jeffs.jpg";

            info.AddTerm(
                "President",
                new DateTime(1801, 3, 4),
                new DateTime(1809, 3, 4),
                3);

            info.BirthDate = new DateTime(1743, 4, 13);
            info.DeathDate = new DateTime(1826, 7, 4);

            info.BirthCity  = "Shadwell";
            info.BirthState = "Virginia";

            info.DeathCity  = "Charlottesville";
            info.DeathState = "Virginia";

            return(info);
        }