Ejemplo n.º 1
0
        public ActionResult CreateFish()
        {
            string userNameActual = Request.Form["userName"];
            int    speciesId      = Int32.Parse(Request.Form["speciesId"]);
            string firstName      = Request.Form["firstName"];
            string lastName       = Request.Form["lastName"];
            string userPassword   = Request.Form["userPassword"];
            Fish   newFish        = new Fish(firstName, lastName, speciesId, userNameActual, userPassword);

            newFish.Save();
            int    newSessionId = Fish.Login(Request.Form["userName"], Request.Form["userPassword"]);
            string fishBio      = Request.Form["bio"];

            newFish.AddBio(fishBio);

            string selectedSpecies = Request.Form["chosenSpecies"];

            if (selectedSpecies != null)
            {
                String[] speciesIds = selectedSpecies.Split(',');
                foreach (var species in speciesIds)
                {
                    int     speciesIdInt = int.Parse(species);
                    Species newSpecies   = Species.Find(speciesIdInt);
                    newFish.AddSpecies(newSpecies);
                }
            }
            return(RedirectToAction("ViewProfile", new { sessionId = newSessionId }));
        }