Example #1
0
        public void DeleteHitLocation(int id)
        {
            HitLocation hitLocationToBeDeleted = (from h in _repo.Query <HitLocation>()
                                                  where h.Id == id
                                                  select h).FirstOrDefault();

            _repo.Delete(hitLocationToBeDeleted);
        }
Example #2
0
        public void DeletePlayer(int id)
        {
            Player playerToBeDeleted = (from p in _repo.Query <Player>()
                                        where p.Id == id
                                        select p).FirstOrDefault();

            _repo.Delete(playerToBeDeleted);
        }
        public void DeleteGame(int id)
        {
            Player player1, player2;

            Game gameToBeDeleted = (from g in _repo.Query <Game>()
                                    where g.Id == id
                                    select g).FirstOrDefault();

            GamesView gameData = GetGame(id);

            player1 = (from p in _repo.Query <Player>()
                       where p.Id == gameData.Player1.Id
                       select p).FirstOrDefault();

            player2 = (from p in _repo.Query <Player>()
                       where p.Id == gameData.Player2.Id
                       select p).FirstOrDefault();

            // adjust the player's Win/Losses:

            if (gameToBeDeleted.Player1Score > gameToBeDeleted.Player2Score)
            {
                player1.Wins--;
                player2.Losses--;
            }
            else
            {
                player2.Wins--;
                player1.Losses--;
            }
            _db.SaveChanges();

            //delete the game:
            _repo.Delete(gameToBeDeleted);

            //delete the game's hit locations:

            List <HitLocation> gameHitLocs = _hitLocationSer.GetHitLocationsGame(id);

            if (gameHitLocs.Count != 0)
            {
                _hitLocationSer.DeleteHitLocationsGame(id);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            ProcessPearson processPearson = new ProcessPearson();

            IPerson person = new Person()
            {
                Name = "Erick"
            };


            person.Run();

            StaticPerson.Run();

            processPearson.ProcessNameWithoutReference(person);

            Console.WriteLine(person.Name);

            RunDelegate(new MyDelegate(processPearson.MyMethodOne), 2);
            RunDelegate(new MyDelegate(processPearson.MyMethodTwo), 33);

            person = new Humman();
            person.Run();


            //ProductRespository productRespository = new ProductRespository();

            GenericRespository <Product> productRespository = new GenericRespository <Product>();

            productRespository.Insert(new Product {
                ProductId = 1, Description = "Teclado"
            });

            Product mouse = new Product {
                ProductId = 2, Description = "Mouse"
            };

            productRespository.Insert(mouse);

            Product monitor = new Product {
                ProductId = 3, Description = "Monitor"
            };

            productRespository.Insert(monitor);

            productRespository.Update(monitor, new Product {
                ProductId = 3, Description = "Monitor V2"
            });
            productRespository.Delete(mouse);

            List <Product> products = productRespository.List();

            GenericRespository <Customer> customerRespository = new GenericRespository <Customer>();
            Customer customer = new Customer {
                CustomerId = 1, Name = "Erick", Lastname = "Aróstegui"
            };

            customerRespository.Insert(customer);
            List <Customer> customers = customerRespository.List();

            GenericRespository <Sale> saleRespository = new GenericRespository <Sale>();
            Sale sale = new Sale {
                Id = 1, Description = "Venta de Laptop", Total = 2500
            };

            saleRespository.Insert(sale);
            List <Sale> sales = saleRespository.List();

            saleRespository.DoWork <Customer>(sale, customer);

            ProductRunnerService productRunnerService = new ProductRunnerService();

            productRunnerService.Run();

            CustomerRunnerService customerRunnerService = new CustomerRunnerService();

            customerRunnerService.Run();
        }