예제 #1
0
        public ActionResult Login()
        {
            Dictionary <string, object> model = new Dictionary <string, object> ();

            string username = Request.Form["username"];
            string password = Request.Form["password"];

            List <Person> allUsers = Person.GetAll();


            foreach (var person in allUsers)
            {
                if (person.GetName() == username && person.GetPassword() == password)
                {
                    List <Experience> newestExperiences = Experience.GetAll();
                    List <City>       allCities         = City.GetAll();

                    model.Add("user", person);
                    model.Add("newest-experiences", newestExperiences);
                    model.Add("all-cities", allCities);

                    return(View("IndexUser", model));
                }
            }
            return(View("Login"));
        }
예제 #2
0
        public void GetAll_ExperiencesEmptyAtFirst_0()
        {
            //Arrange, Act
            int result = Experience.GetAll().Count;

            //Assert
            Assert.AreEqual(0, result);
        }
예제 #3
0
        public ActionResult Index()
        {
            Dictionary <string, object> model             = new Dictionary <string, object> ();
            List <Experience>           newestExperiences = Experience.GetAll();
            List <City> allCities = City.GetAll();

            model.Add("newest-experiences", newestExperiences);
            model.Add("all-cities", allCities);

            return(View("Index", model));
        }
예제 #4
0
        public ActionResult IndexUser(int userId)
        {
            Dictionary <string, object> model   = new Dictionary <string, object> ();
            Person            thisPerson        = Person.Find(userId);
            List <Experience> newestExperiences = Experience.GetAll();
            List <City>       allCities         = City.GetAll();

            model.Add("user", thisPerson);
            model.Add("newest-experiences", newestExperiences);
            model.Add("all-cities", allCities);

            return(View("IndexUser", model));
        }
예제 #5
0
        public ActionResult SignUpPost()
        {
            Dictionary <string, object> model = new Dictionary <string, object> ();

            Person            newPerson      = new Person(Request.Form["name"], Request.Form["dob"], Request.Form["country"], Request.Form["email"], Request.Form["phone"], Request.Form["password"]);
            List <Experience> allExperiences = Experience.GetAll();
            List <City>       allCities      = City.GetAll();

            newPerson.Save();
            model.Add("user", newPerson);
            model.Add("newest-experiences", allExperiences);
            model.Add("all-cities", allCities);

            return(View("IndexUser", model));
        }
예제 #6
0
        public void Save_SavesToDatabase_Experience()
        {
            //Arrange
            Experience testExperience = new Experience(1, 2, "Sky Diving", "Blah Blah..", "/hjfsddjf.com", 150);

            //Act
            testExperience.Save();
            List <Experience> result   = Experience.GetAll();
            List <Experience> testList = new List <Experience> {
                testExperience
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
예제 #7
0
        public void Save_AssignsIdToObject_id()
        {
            //Arrange
            Experience testExperience = new Experience(1, 2, "Sky Diving", "Blah Blah..", "/hjfsddjf.com", 150);

            testExperience.Save();

            //Act
            Experience savedExperience = Experience.GetAll()[0];

            int result = savedExperience.GetId();
            int testId = testExperience.GetId();

            //Assert
            Assert.AreEqual(testId, result);
        }
예제 #8
0
        public ActionResult AddViewExperience(int userId)
        {
            Dictionary <string, object> model = new Dictionary <string, object> ();

            Person thisPerson = Person.Find(userId);
            int    UserId     = userId;

            Experience newExperience = new Experience(Int32.Parse(Request.Form["experience-location"]),
                                                      UserId, Request.Form["experience-title"], Request.Form["experience-description"], Request.Form["experience-photo"], Int32.Parse(Request.Form["experience-price"]));

            newExperience.Save();
            int TagValue = Int32.Parse(Request.Form["number-loop"]);

            for (var i = 1; i <= TagValue; i++)
            {
                Console.WriteLine("tag" + Request.Form["tag-name" + i]);
                Tag newTag = new Tag(Request.Form["tag-name" + i]);
                if (newTag.IsNewTag() == true)
                {
                    newTag.Save();
                    newExperience.AddTag(newTag);
                }
                else
                {
                    Tag repeatTag = newTag.FindTag();
                    newExperience.AddTag(repeatTag);
                }
            }
            List <Experience> newestExperiences = Experience.GetAll();
            List <City>       allCities         = City.GetAll();

            model.Add("user", thisPerson);
            model.Add("newest-experiences", newestExperiences);
            model.Add("all-cities", allCities);


            return(View("IndexUser", model));
        }