public ActionResult Create([Bind(Include = "Id,NameClub,City")] Club club) { if (ModelState.IsValid) { db.Club.Add(club); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(club)); }
public ActionResult Create([Bind(Include = "Id,Firstname,Lastname,Number,ClubId")] Player player) { if (ModelState.IsValid) { db.Player.Add(player); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClubId = new SelectList(db.Club, "Id", "NameClub", player.ClubId); return(View(player)); }
public ActionResult Create([Bind(Include = "PlayerId,FirstName,LastName,Phone,Email,Paid,ShirtSize,ShortsSize,IsActive,Updated,UpdatedBy")] Player player) { if (ModelState.IsValid) { player.Updated = DateTime.Now; player.UpdatedBy = "alex"; db.Players.Add(player); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(player)); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { User user = null; using (SoccerEntities db = new SoccerEntities()) { user = db.Users.FirstOrDefault(u => u.Email == model.Name); } if (user == null) { using (SoccerEntities db = new SoccerEntities()) { db.Users.Add(new User { Email = model.Name, Password = model.Password, Age = model.Age, RoleId = 2 }); db.SaveChanges(); user = db.Users.Where(u => u.Email == model.Name && u.Password == model.Password).FirstOrDefault(); } if (user != null) { FormsAuthentication.SetAuthCookie(model.Name, true); return(RedirectToAction("Index", "Team1")); } } else { ModelState.AddModelError("", "Uzytkownik z takim loginem juz istnieje"); } } return(View(model)); }
public ActionResult Delete_p(int playerId, int teamId) { SoccerEntities footballcontext = new SoccerEntities(); Player player = footballcontext.Players.Single(pl => pl.ID == playerId); footballcontext.Players.Remove(player); footballcontext.SaveChanges(); return(RedirectToAction("Index", new { teamId = player.TeamID })); }
public ActionResult Edit(Player player) { SoccerEntities db = new SoccerEntities(); { db.Entry(player).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { teamId = player.TeamID })); } // return View(player); }
public ActionResult Edit(Team1 team) { SoccerEntities db = new SoccerEntities(); if (ModelState.IsValid) { db.Entry(team).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(team)); }
public ActionResult Delete_p(int teamId) { SoccerEntities footballcontext = new SoccerEntities(); Team1 team = footballcontext.Team1.Single(py => py.ID == teamId); IEnumerable <Player> players = footballcontext.Players.Where(pl => pl.TeamID == teamId); foreach (var Item in players) { footballcontext.Players.Remove(Item); } footballcontext.Team1.Remove(team); footballcontext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(Team1 team) { SoccerEntities footballcontext = new SoccerEntities(); if (ModelState.IsValid) { try { footballcontext.Team1.Add(team); footballcontext.SaveChanges(); return(RedirectToAction("Index")); } catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException ex) { Console.WriteLine(ex.InnerException); } } return(View(team)); }
public ActionResult Create([Bind(Include = "GameId,GameDateTime,Location,Updated,UpdatedBy,SendEmail")] Game game) { if (ModelState.IsValid) { //Game game = gmv.Game; game.Updated = DateTime.Now; //TODO: Get current UserName here game.UpdatedBy = "alex"; db.Games.Add(game); db.SaveChanges(); if (game.SendEmail) { List <Player> recipients = db.Players.ToList(); SendEmail(game, recipients); } return(RedirectToAction("Index")); } return(View(game)); }
public ActionResult CreateForTeam(Player player) { SoccerEntities footballcontext = new SoccerEntities(); if (ModelState.IsValid) { try { player.Photo = "~/Photo.anonim.png"; footballcontext.Players.Add(player); footballcontext.SaveChanges(); return(RedirectToAction("Index", new { teamId = player.TeamID })); } catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException ex) { Console.WriteLine(ex.InnerException); } } return(View(player)); }