Ejemplo n.º 1
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var player = new StandarPlayerModel {
                    Name     = collection["Name"],
                    LastName = collection["LastName"],
                    Club     = collection["Club"],
                    Position = collection["Position"],
                    Salary   = int.Parse(collection["Salary"]),
                };

                if (player.Save())
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(player));
                }
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        // GET: StandarPlayer
        public ActionResult Index()
        {
            var player1 = new StandarPlayerModel {
                Name = "José", LastName = "De Leon", Position = "MD", Club = "CHI", Salary = 30000,
            };
            var player2 = new StandarPlayerModel {
                Name = "Javier", LastName = "Morales", Position = "MD", Club = "CHI", Salary = 30000,
            };

            player1.Save();
            player2.Save();

            return(View(Storage.Instance.playerList));
        }
Ejemplo n.º 3
0
        public ActionResult Edit(string id, FormCollection collection)
        {
            try
            {
                var player = new StandarPlayerModel
                {
                    Name     = collection["Name"],
                    LastName = collection["LastName"],
                    Club     = collection["Club"],
                    Position = collection["Position"],
                    Salary   = int.Parse(collection["Salary"]),
                };
                player.Save();
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }