コード例 #1
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));
        }