コード例 #1
0
ファイル: SellCarCommand.cs プロジェクト: Fooxboy/HydraBot
        public void Execute(Message msg, IMessageSenderService sender, IBot bot)
        {
            if (Main.Api.Users.IsBanned(msg))
            {
                return;
            }

            if (!Main.Api.Users.CheckUser(msg))
            {
                var kb2 = new KeyboardBuilder(bot);
                kb2.AddButton("➕ Зарегистрироваться", "start");
                sender.Text("❌ Вы не зарегистрированы, нажмите на кнопку ниже, чтобы начать", msg.ChatId, kb2.Build());
                return;
            }

            var user = Main.Api.Users.GetUser(msg);

            UsersCommandHelper.GetHelper().Add("sellcar", user.Id);

            sender.Text("⌛ Укажите Id пользователя (в боте), которому хотите продать авто и цену." +
                        "\n ❓ Например: 123 10000", msg.ChatId);

            using (var db = new Database())
            {
                var carSell = new SellCar();
                carSell.Id      = db.SellCars.Count() + 1;
                carSell.CarId   = msg.Payload.Arguments[0].ToLong();
                carSell.OwnerId = user.Id;
                db.SellCars.Add(carSell);
                db.SaveChanges();
            }
        }
コード例 #2
0
ファイル: DataTest.cs プロジェクト: pawrob/TPR_PB_RM
        public void GetFactureTest()
        {
            Car           Car1 = new Car("Alfa Romeo", "Brera", "Italia Independent", 210, "Matte Grey", VehicleType.Coupe, FuelType.Diesel, Transmission.Manual);
            Client        c1   = new Client("Jan", "Kowalski", 111111, Guid.Parse("1981e86b-2f16-4b61-9d91-664bfed3ebc5"));
            WarehouseItem wi1  = new WarehouseItem(Car1, 10000, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b90b"));
            SellCar       f1   = new SellCar(c1, wi1, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b90b"), Convert.ToDateTime("5.11.2020"));

            dataRepository.AddFacture(f1);
            Assert.IsTrue(dataRepository.GetFacture(f1.Id) == f1);
        }
コード例 #3
0
ファイル: DataRepository.cs プロジェクト: pawrob/TPR_PB_RM
        public void UpdateFacture(Guid id, SellCar facture)
        {
            SellCar foundFacture = dataContext.SoldCars.First(f => f.Id.Equals(id));

            if (foundFacture == null)
            {
                throw new ArgumentException($"Facture with {id} id doesn't exist");
            }
            dataContext.SoldCars[dataContext.SoldCars.IndexOf(foundFacture)] = facture;
        }
コード例 #4
0
ファイル: DataRepository.cs プロジェクト: pawrob/TPR_PB_RM
 public void DeleteFacture(SellCar facture)
 {
     if (dataContext.SoldCars.Contains(facture))
     {
         dataContext.SoldCars.Remove(facture);
     }
     else
     {
         throw new ArgumentException($"There isn't facture with {facture.Id} id in warehouse");
     }
 }
コード例 #5
0
        public void UpdateFactureTest()
        {
            Assert.AreEqual(0, dataService.GetAllFactures().Count());
            dataService.AddClient("Andrzej", "Nowak", 123456789);
            dataService.AddClient("Marian", "Kowalski", 987654321);
            dataService.AddCar("Skoda", "Fabia", "Style", 210, "Silver Metalic", VehicleType.Small_car, FuelType.Petrol, Transmission.Manual);
            dataService.AddWarehouseItem(dataService.GetAllCars().First(), 10000);
            dataService.AddFacture(dataService.GetAllClients().First(), dataService.GetAllWarehouseItems().First());
            SellCar f2 = new SellCar(dataService.GetAllClients().Last(), dataService.GetAllWarehouseItems().First(), new Guid(), DateTime.Now);

            dataService.updateFacture(dataService.GetAllFactures().First().Id, f2);

            Assert.AreEqual(dataService.GetAllFactures().First(), f2);
        }
コード例 #6
0
ファイル: DataRepository.cs プロジェクト: pawrob/TPR_PB_RM
 public void AddFacture(SellCar facture)
 {
     try
     {
         dataContext.SoldCars.Add(facture);
     }
     catch (ArgumentNullException e)
     {
         throw new ArgumentNullException($"Facture with Id {facture.Id} do not exist.", e);
     }
     catch (ArgumentException e)
     {
         throw new ArgumentException($"Facture with Id {facture.Id} already exists.", e);
     }
 }
コード例 #7
0
ファイル: DataTest.cs プロジェクト: pawrob/TPR_PB_RM
        public void UpdateFactureTest()
        {
            Car           Car1 = new Car("Alfa Romeo", "Brera", "Italia Independent", 210, "Matte Grey", VehicleType.Coupe, FuelType.Diesel, Transmission.Manual);
            Client        c1   = new Client("Jan", "Kowalski", 111111, Guid.Parse("1981e86b-2f16-4b61-9d91-664bfed3ebc5"));
            WarehouseItem wi1  = new WarehouseItem(Car1, 10000, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b90b"));
            SellCar       f1   = new SellCar(c1, wi1, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b90b"), Convert.ToDateTime("5.11.2020"));

            dataRepository.AddFacture(f1);
            Car           Car2 = new Car("Skoda", "Fabia", "Style", 210, "Silver Metalic", VehicleType.Small_car, FuelType.Petrol, Transmission.Manual);
            WarehouseItem wi2  = new WarehouseItem(Car2, 210000, Guid.Parse("2273ec6b-7c26-4bce-8ec0-00a2773d108a"));
            SellCar       f2   = new SellCar(c1, wi2, Guid.Parse("bef406e7-61b5-4a14-86b7-d20af86cb752"), Convert.ToDateTime("8.11.2020"));

            dataRepository.UpdateFacture(f1.Id, f2);

            Assert.AreEqual(f2, dataRepository.GetAllFactures().First());
        }
コード例 #8
0
ファイル: DataManualFiller.cs プロジェクト: pawrob/TPR_PB_RM
        public void InsertData(DataContext dataContext)
        {
            Client c1   = new Client("John", "Doe", 000000000, Guid.NewGuid());
            Client c2   = new Client("Jack", "Karabinczyk", 213721151, Guid.NewGuid());
            Client c3   = new Client("Peter", "Parker", 123456789, Guid.NewGuid());
            Car    Car2 = new Car("Skoda", "Fabia", "Style", 210, "Silver Metalic", VehicleType.Small_car, FuelType.Petrol, Transmission.Manual);
            Car    Car1 = new Car("Alfa Romeo", "Brera", "Italia Independent", 210, "Matte Grey", VehicleType.Coupe, FuelType.Diesel, Transmission.Manual);

            WarehouseItem wi1 = new WarehouseItem(Car1, 10000, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b80b"));
            SellCar       f1  = new SellCar(c1, wi1, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b90b"), Convert.ToDateTime("5.11.2020"));
            BuyCar        b1  = new BuyCar(wi1, Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b91b"), Convert.ToDateTime("5.11.2020"));

            dataContext.Clients.Add(c1);
            dataContext.Clients.Add(c2);
            dataContext.Clients.Add(c3);
            dataContext.Cars.Add(Guid.Parse("594e4c41-7e20-432c-9773-085d75e9b80d"), Car1);
            dataContext.Cars.Add(Guid.Parse("694e4c41-7e20-432c-9773-085d75e9b80d"), Car2);
            dataContext.WarehouseItems.Add(wi1);
            dataContext.BoughtCars.Add(b1);
            dataContext.SoldCars.Add(f1);
        }
コード例 #9
0
        public void UpdateCarShop(SellCar sell)
        {
            SimpleMapper <UpdateSellCarDto, SellCar> .Instance.ApplyChanges(this, sell);

            sell.Id = Id;
        }
コード例 #10
0
 public void updateFacture(Guid id, SellCar facture)
 {
     dataRepository.UpdateFacture(id, facture);
 }
コード例 #11
0
 public void DeleteFacture(SellCar facture)
 {
     dataRepository.DeleteFacture(facture);
 }