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()); } }
// 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)); }
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()); } }