public PlayersBm DeletePlayer(int?id) { Player player = Context.Players.Find(id); PlayersBm model = Mapper.Map <Player, PlayersBm>(player); return(model); }
public void Edit(PlayersBm playersBm) { Player player = Mapper.Map <PlayersBm, Player>(playersBm); Context.Entry(player).State = EntityState.Modified; Context.SaveChanges(); }
public ActionResult EditPlayer([Bind(Include = "Id,FirstName,LastName,Age,DateOfBirth,Description,Position,ImageUrl,VideoUrl,Number,Nationality")] PlayersBm playersBm) { if (ModelState.IsValid) { service.Edit(playersBm); return(RedirectToAction("AllPlayers")); } return(this.View(playersBm)); }
public void AddPlayer(PlayersBm model, string user) { var userName = Context.Users.FirstOrDefault(x => x.UserName == user); Player player = Mapper.Map <PlayersBm, Player>(model); player.AdminAuthor = userName; Context.Players.Add(player); Context.SaveChanges(); }
public ActionResult AddPlayer(PlayersBm model) { var user = User.Identity.Name; if (ModelState.IsValid) { service.AddPlayer(model, user); RedirectToAction("AllPlayers"); } return(this.View(model)); }
public ActionResult DeletePlayer(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PlayersBm blogArticleBm = service.DeletePlayer(id); if (blogArticleBm == null) { return(HttpNotFound()); } return(View(blogArticleBm)); }