Beispiel #1
0
        public ActionResult Delete(int id)
        {
            var player = _playersRepository.FindBy(c => c.Id == id).Single();

            _playersRepository.Delete(player);
            _playersRepository.Save();

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult <string> Delete(int id)
        {
            bool successful = _pr.Delete(id);

            if (!successful)
            {
                return(BadRequest());
            }
            return(Ok());
        }
        public string Delete(int id)
        {
            Player exists = _repo.Get(id);

            if (exists == null)
            {
                throw new Exception("Invalid Id");
            }
            _repo.Delete(id);
            return(" that players been iced, eh");
        }
Beispiel #4
0
        public IHttpActionResult Delete(Guid id)
        {
            bool isDeleted = _repo.Delete(id);

            if (isDeleted)
            {
                return(Content <Player>(HttpStatusCode.NoContent, null));
            }

            return(NotFound());
        }
Beispiel #5
0
        internal object Delete(string creatorId, int id)
        {
            var exists = _repo.GetById(id);

            if (exists == null)
            {
                throw new Exception("Invalid Id");
            }
            if (exists.CreatorId != creatorId)
            {
                throw new Exception("I can't let you do that");
            }
            _repo.Delete(id);
            return("Successfully deleted");
        }
        public async Task DeletesPlayer()
        {
            var mockPlayers = new List <Player>
            {
                new Player {
                    Id = 1
                },
                new Player {
                    Id = 2
                },
                new Player {
                    Id = 3
                }
            };

            using (var context = new ApplicationDbContext(_options))
            {
                context.Players.AddRange(mockPlayers);

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var playersRepository = new PlayersRepository(context);

                var player = mockPlayers[0];
                await playersRepository.Delete(player);
            }

            using (var context = new ApplicationDbContext(_options))
            {
                Assert.Equal(2, context.Players.Count());
                Assert.Null(context.Players.SingleOrDefault(x => x.Id == 1));
            }
        }