internal string Delete(int id)
 {
     if (_repo.Delete(id))
       {
     return "game deleted.";
       }
       throw new Exception("Could not delete DB data");
 }
예제 #2
0
        public ActionResult <string> Delete(int id)
        {
            bool successful = _gr.Delete(id);

            if (!successful)
            {
                return(BadRequest());
            }
            return(Ok());
        }
예제 #3
0
        public string Delete(int id)
        {
            Game exists = _repo.Get(id);

            if (exists == null)
            {
                throw new Exception("Invalid Id");
            }
            _repo.Delete(id);
            return(" that games been iced, eh");
        }
예제 #4
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         System.Threading.Thread.Sleep(1000);
         gamesRepositorie.Delete(id);
         return(Ok());
     }
     catch (Exception)
     {
         return(InternalServerError());
     }
 }
        public async Task Delete_WhenItemIdIsProvided_ShouldDeleteItemFromDatabase()
        {
            var item = new Game()
            {
                Name      = "example",
                CreatedBy = "user",
                IsDeleted = false,
                Ready     = true
            };
            var entityRepository = new GamesRepository(_dbContext);
            var added            = await entityRepository.Add(item);

            var deleted = await entityRepository.Delete(added.Id);

            var items = _dbContext.Games.ToList();

            items.Count().ShouldBe(0);
            deleted.Name.ShouldBe(added.Name);
            deleted.IsDeleted.ShouldBe(added.IsDeleted);
            deleted.Ready.ShouldBe(added.Ready);
        }
예제 #6
0
 public async System.Threading.Tasks.Task <OperationResult <Game> > DeleteGame(int id)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Game> >(() =>
     {
         OperationResult <Game> result = new OperationResult <Game>();
         try
         {
             Game game = GamesRepository.Read(id);
             if (game != null)
             {
                 if (IsInCompany(game.CompanyId) || game.CreatorId == CurrentUser.Id || UserStore.IsInRole(CurrentUser, RoleNames.Admin))
                 {
                     result.Result = GamesRepository.Delete(id);
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
예제 #7
0
        public async Task DeletesGame()
        {
            var mockGames = new List <Game>
            {
                new Game {
                    Id = 1
                },
                new Game {
                    Id = 2
                },
                new Game {
                    Id = 3
                }
            };

            using (var context = new ApplicationDbContext(_options))
            {
                context.Games.AddRange(mockGames);

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var gamesRepository = new GamesRepository(context);

                var game = mockGames[0];
                await gamesRepository.Delete(game);
            }

            using (var context = new ApplicationDbContext(_options))
            {
                Assert.Equal(2, context.Games.Count());
                Assert.Null(context.Games.SingleOrDefault(x => x.Id == 1));
            }
        }
예제 #8
0
 public async System.Threading.Tasks.Task <OperationResult <MyGameReponseSingle> > DeleteMyGame(int id)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <MyGameReponseSingle> >(() =>
     {
         OperationResult <MyGameReponseSingle> result = new OperationResult <MyGameReponseSingle>();
         try
         {
             Game game = GamesRepository.Read(id);
             if (game != null)
             {
                 if (game.CreatorId == CurrentUser.Id)
                 {
                     game.CreatorId = Guid.Empty;
                     result.Result = GamesRepository.Delete(id);
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }