Пример #1
0
        public async Task <bool> Post(FuelPrelevement myPrelevement)
        {
            using (var db = new StationContext())
            {
                if (myPrelevement.PrelevementGuid == Guid.Empty)
                {
                    myPrelevement.PrelevementGuid = Guid.NewGuid();
                }

                var citerneGuid = db.Pompes.Find(myPrelevement.PompeGuid).CiterneGuid;
                if (citerneGuid != null)
                {
                    myPrelevement.CiterneGuid = (Guid)citerneGuid;
                }
                else
                {
                    throw new ArgumentException("CAN_NOT_FIND_CITERNE");
                }

                myPrelevement.CurrentPrice = (await FuelManager.GetFuelCurrentPrice(db.Pompes.Find(myPrelevement.PompeGuid).Citerne.FuelGuid));

                myPrelevement.DateAdded    = DateTime.Now;
                myPrelevement.LastEditDate = DateTime.Now;

                db.Set <FuelPrelevement>().Add(myPrelevement);
                return(await db.SaveChangesAsync() > 0);
            }
        }
Пример #2
0
        public async Task <bool> Post(Purchase myPurchase)
        {
            using (var db = new StationContext())
            {
                switch (myPurchase.ProductType)
                {
                case ProductType.Fuel:
                    myPurchase.Sum         = myPurchase.Quantity * (await FuelManager.GetFuelCurrentPrice(myPurchase.ProductGuid));
                    myPurchase.Description = $"{myPurchase.Quantity.ToString("0.##\\ L")} {(await db.Fuels.FindAsync(myPurchase.ProductGuid)).Libel}";
                    break;

                case ProductType.Oil:
                    myPurchase.Sum         = myPurchase.Quantity * (await OilManager.StaticGet(myPurchase.ProductGuid)).CurrentUnitPrice;
                    myPurchase.Description = $"{"Bidon".ToQuantity((int) myPurchase.Quantity)} {(await db.Oils.FindAsync(myPurchase.ProductGuid)).Libel}";
                    break;
                }

                if (myPurchase.PurchaseGuid == Guid.Empty)
                {
                    myPurchase.PurchaseGuid = Guid.NewGuid();
                }
                if (myPurchase.PurchaseState == PurchaseState.Paid)
                {
                    myPurchase.PurchaseDate = DateTime.Now;
                }
                myPurchase.DateAdded    = myPurchase.PurchaseDate;
                myPurchase.LastEditDate = DateTime.Now;

                db.Purchases.Add(myPurchase);
                return(await db.SaveChangesAsync() > 0);
            }
        }
Пример #3
0
        internal async static Task <double> StaticGetRevenue(DateTime startDate, DateTime endDate)
        {
            double solde = 0;

            solde += await OilManager.GetSold(startDate, endDate);

            solde += await FuelManager.GetSold(startDate, endDate);

            solde += await SalesManager.StaticGetPurchasedSum(ProductType.Service, PurchaseState.Paid, startDate, endDate);

            solde += await StaticGetSoldeCaisse(startDate, endDate);

            solde -= await StaticGetPaidSalary(startDate, endDate);

            solde -= await SalesManager.StaticGetPurchasedSum(ProductType.Fuel, PurchaseState.UnPaid, startDate, endDate);

            solde -= await SalesManager.StaticGetPurchasedSum(ProductType.Oil, PurchaseState.UnPaid, startDate, endDate);

            solde -= await SalesManager.StaticGetPurchasedSum(ProductType.Fuel, PurchaseState.NotPaying, startDate, endDate);

            solde -= await SalesManager.StaticGetPurchasedSum(ProductType.Oil, PurchaseState.NotPaying, startDate, endDate);

            return(solde);
        }