Exemplo n.º 1
0
        public PlayersBm DeletePlayer(int?id)
        {
            Player    player = Context.Players.Find(id);
            PlayersBm model  = Mapper.Map <Player, PlayersBm>(player);

            return(model);
        }
Exemplo n.º 2
0
        public void Edit(PlayersBm playersBm)
        {
            Player player = Mapper.Map <PlayersBm, Player>(playersBm);

            Context.Entry(player).State = EntityState.Modified;
            Context.SaveChanges();
        }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        public ActionResult AddPlayer(PlayersBm model)
        {
            var user = User.Identity.Name;

            if (ModelState.IsValid)
            {
                service.AddPlayer(model, user);
                RedirectToAction("AllPlayers");
            }

            return(this.View(model));
        }
Exemplo n.º 6
0
        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));
        }