public ActionResult Create(CreateTactics model) { if (this.ModelState.IsValid) { var authorId = this.User.Identity.GetUserId(); var tactic = new Football { TacticName = model.TacticName, Description = model.Description, Formation = model.Formation, PlayerPosition = model.PlayerPosition, Image = model.Image, AuthorId = authorId }; var db = new FootballDbContext(); db.Footballs.Add(tactic); db.SaveChanges(); return(RedirectToAction("Details", new { id = tactic.Id })); } return(View(model)); }
public ActionResult Edit(CreateTactics models) { if (ModelState.IsValid) { using (var db = new FootballDbContext()) { var tactics = db.Footballs.Find(models.Id); tactics.Description = models.Description; tactics.Formation = models.Formation; tactics.PlayerPosition = models.PlayerPosition; tactics.TacticName = models.TacticName; tactics.Image = models.Image; db.SaveChanges(); } return(RedirectToAction("TacticsDetails", new { id = models.Id })); } return(View(models)); }