コード例 #1
0
        protected virtual Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(identityService);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(GarmentSewingBlockingPlanLogic)))
            .Returns(new GarmentSewingBlockingPlanLogic(identityService, dbContext));

            return(serviceProviderMock);
        }
コード例 #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            /* Update Database */
            using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                SalesDbContext context = serviceScope.ServiceProvider.GetService <SalesDbContext>();
                context.Database.Migrate();
            }

            app.UseAuthentication();
            app.UseCors(SALES_POLICY);
            app.UseMvc();
        }
コード例 #3
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SalesDbContext salesDbContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            salesDbContext.Database.EnsureCreated();

            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthorization();
            app.UseApiDocumentation();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
コード例 #4
0
        protected virtual Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(identityService);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(GarmentPreSalesContractLogic)))
            .Returns(new GarmentPreSalesContractLogic(identityService, dbContext));

            CostCalculationGarmentMaterialLogic costCalculationGarmentMaterialLogic = new CostCalculationGarmentMaterialLogic(serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(CostCalculationGarmentMaterialLogic)))
            .Returns(costCalculationGarmentMaterialLogic);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(CostCalculationGarmentLogic)))
            .Returns(new CostCalculationGarmentLogic(costCalculationGarmentMaterialLogic, serviceProviderMock.Object, identityService, dbContext));

            serviceProviderMock
            .Setup(x => x.GetService(typeof(AvailableROGarmentReportLogic)))
            .Returns(new AvailableROGarmentReportLogic(dbContext, identityService));

            var azureImageFacadeMock = new Mock <IAzureImageFacade>();

            azureImageFacadeMock
            .Setup(s => s.DownloadImage(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync("");

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IAzureImageFacade)))
            .Returns(azureImageFacadeMock.Object);

            return(serviceProviderMock);
        }
コード例 #5
0
        //TODO FINISH THE METHOD LAST
        public static void Seed(SalesDbContext dbContext)
        {
            var storeNames = File.ReadAllLines(@"D:\SalesDataBaseCodeFirstEntityFrameworkCore\Data\RandomStoreNames.txt");

            foreach (var storeName in storeNames)
            {
                dbContext.Stores.Add(new Store {
                    StoreName = storeName
                });
            }

            dbContext.SaveChanges();

            var productNames = File.ReadAllLines(@"D:\SalesDataBaseCodeFirstEntityFrameworkCore\Data\RandomProductNames.txt");

            foreach (var productName in productNames)
            {
                //dbContext.Products.Add()
            }
        }
コード例 #6
0
        protected Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(identityService);

            var spinningLogic = new SpinningSalesContractLogic(serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(SpinningSalesContractLogic)))
            .Returns(spinningLogic);

            return(serviceProviderMock);
        }
コード例 #7
0
        public void SimpleHappyFlow_ShoppingBasketItemTest()
        {
            //Arrange
            var currentDateTime   = DateTime.UtcNow;
            var shoppingCartItems = new List <ShoppingBasketItem>();
            var shoppingBasketId  = Guid.NewGuid();

            //seedProducts.Add(new ShoppingBasketProduct() {ProductId =10, ProductName="ML Mountain Seat Assembly",Price = 147.14m });
            shoppingCartItems.Add(new ShoppingBasketItem()
            {
                ShoppingBasketID = shoppingBasketId, ProductID = 514, Quantity = 4, DateCreated = currentDateTime, ModifiedDate = currentDateTime
            });
            shoppingCartItems.Add(new ShoppingBasketItem()
            {
                ShoppingBasketID = shoppingBasketId, ProductID = 515, Quantity = 2, DateCreated = currentDateTime, ModifiedDate = currentDateTime
            });
            using (var context = new SalesDbContext(_options))
            {
                foreach (var item in shoppingCartItems)
                {
                    context.ShoppingBasketItems.Add(item);
                }
                //Act
                context.SaveChanges();
                //Assert
                var results = context.ShoppingBasketItems.Where(x => x.ShoppingBasketID == shoppingBasketId);
                results.Should().NotBeNullOrEmpty();
                results.Count().Should().Be(2);
                var prod1 = results.Where(x => x.ProductID == 514).SingleOrDefault();
                var prod2 = results.Where(x => x.ProductID == 515).SingleOrDefault();
                prod1.Should().NotBeNull();
                prod1.Quantity.Should().Be(4);
                prod1.DateCreated.Should().Be(currentDateTime);
                prod1.ModifiedDate.Should().Be(currentDateTime);

                prod2.Should().NotBeNull();
                prod2.Quantity.Should().Be(2);
                prod2.DateCreated.Should().Be(currentDateTime);
                prod2.ModifiedDate.Should().Be(currentDateTime);
            }
        }
コード例 #8
0
        public ActionResult Edit([Bind(Include = "ID,Name,QTY,Price,Discontinued")] Product product)
        {
            using (var ctx = new SalesDbContext())
            {
                if (ModelState.IsValid)
                {
                    var oldProduct = ctx.Products.Where(x => x.ID == product.ID).FirstOrDefault();

                    oldProduct.Name         = product.Name;
                    oldProduct.QTY          = product.QTY;
                    oldProduct.LowWarn      = product.LowWarn;
                    oldProduct.Price        = product.Price;
                    oldProduct.Discontinued = product.Discontinued;

                    ProductLog.GenerateProductLog(ctx, product, -product.QTY);
                    ctx.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                return(View(product));
            }
        }
        protected Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(identityService);

            var finishingprintingDetailLogic = new FinishingPrintingSalesContractDetailLogic(serviceProviderMock.Object, identityService, dbContext);
            var finishingprintingLogic       = new FinishingPrintingSalesContractLogic(finishingprintingDetailLogic, serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(FinishingPrintingSalesContractLogic)))
            .Returns(finishingprintingLogic);

            return(serviceProviderMock);
        }
        protected virtual Mock <IServiceProvider> GetBOServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(identityService);

            var garmentBookingOrderItemLogic = new GarmentBookingOrderItemLogic(identityService, serviceProviderMock.Object, dbContext);
            var garmentBookingOrderLogic     = new GarmentBookingOrderLogic(garmentBookingOrderItemLogic, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(GarmentBookingOrderLogic)))
            .Returns(garmentBookingOrderLogic);

            return(serviceProviderMock);
        }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            SalesDbContext dbContext = (SalesDbContext)validationContext.GetService(typeof(SalesDbContext));

            //var duplicateRONo = dbContext.GarmentPurchaseRequests.Where(m => m.RONo.Equals(RONo) && m.Id != Id).Count();
            //IGarmentSalesContract Service = (IGarmentSalesContract)validationContext.GetService(typeof(IGarmentSalesContract));
            if (SCDate == DateTimeOffset.MinValue || SCDate == null)
            {
                yield return(new ValidationResult("Tanggal Sales Contract harus diisi", new List <string> {
                    "RONumber"
                }));
            }
            if (SectionCode == null)
            {
                yield return(new ValidationResult("Seksi harus diisi", new List <string> {
                    "Section"
                }));
            }

            if (BuyerAgentCode == null)
            {
                yield return(new ValidationResult("Buyer Agent harus diisi", new List <string> {
                    "BuyerAgent"
                }));
            }

            if (BuyerBrandCode == null)
            {
                yield return(new ValidationResult("Buyer Brand harus diisi", new List <string> {
                    "BuyerBrand"
                }));
            }

            if (OrderQuantity <= 0)
            {
                yield return(new ValidationResult("Jumlah Order harus lebih dari 0", new List <string> {
                    "OrderQuantity"
                }));
            }
        }
コード例 #12
0
        protected virtual Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IdentityService)))
            .Returns(identityService);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(WeeklyPlanLogic)))
            .Returns(new WeeklyPlanLogic(identityService, dbContext));

            serviceProviderMock
            .Setup(x => x.GetService(typeof(MonitoringRemainingEHLogic)))
            .Returns(new MonitoringRemainingEHLogic(identityService, dbContext));

            return(serviceProviderMock);
        }
コード例 #13
0
        /// <summary>
        /// Create a transaction with items that are being negated from another transaction.
        /// </summary>
        /// <param name="sales">List of Sales to be negated</param>
        /// <returns></returns>
        public ActionResult Return(TransactionRowViewModel t)
        {
            using (var ctx = new SalesDbContext())
            {
                for (int i = 0; i < t.SalesList.Count; i++)
                {
                    if (t.SalesList.ElementAt(i).Void == false)
                    {
                        t.SalesList.RemoveAt(i--);
                    }
                    else
                    {
                        Guid g = t.SalesList.ElementAt(i).ID;
                        Sale s = ctx.Sales.Where(m => m.ID == g).FirstOrDefault();
                        t.SalesList[i] = s;
                        t.SalesList.ElementAt(i).QTY *= -1;
                        t.SalesList.ElementAt(i).Void = true;
                    }
                }
            }

            return(View(t));
        }
コード例 #14
0
        public static void Main()
        {
            var dbContext = new SalesDbContext();

            var products = dbContext.Products
                           .Select(p => new
            {
                p.Name,
                p.Quantity,
                p.Price,
                p.Description
            })
                           .Take(10)
                           .ToList();

            foreach (var product in products)
            {
                Console.WriteLine($"{product.Name} - {product.Quantity} - {product.Price} - {product.Description}");
            }

            var sales = dbContext.Sales
                        .Select(s => new
            {
                s.Date,
                ProductName   = s.Product.Name,
                CustomerEmail = s.Customer.Email,
                StoreName     = s.Store.Name
            })
                        .Take(10)
                        .ToList();

            foreach (var sale in sales)
            {
                Console.WriteLine($"{sale.Date} - {sale.ProductName} - {sale.CustomerEmail} - {sale.StoreName}");
            }
        }
コード例 #15
0
 public GenericRepository(SalesDbContext context)
 {
     this._context = context;
     this._dbSet   = context.Set <T>();
 }
 public CostCalculationGarmentByBuyer2ReportFacade(IServiceProvider serviceProvider, SalesDbContext dbContext)
 {
     this.DbContext       = dbContext;
     this.DbSet           = this.DbContext.Set <CostCalculationGarment>();
     this.IdentityService = serviceProvider.GetService <IdentityService>();
     this.CostCalculationByBuyer2ReportLogic = serviceProvider.GetService <CostCalculationByBuyer2ReportLogic>();
 }
コード例 #17
0
        protected Mock <IServiceProvider> GetServiceProviderMock(SalesDbContext dbContext)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();

            IIdentityService identityService = new IdentityService {
                Username = "******"
            };

            //ROGarmentLogic roGarmentLogic = new ROGarmentLogic(serviceProviderMock.Object, identityService, dbContext);

            CostCalculationGarmentMaterialLogic costCalculationGarmentMaterialLogic = new CostCalculationGarmentMaterialLogic(serviceProviderMock.Object, identityService, dbContext);


            GarmentPreSalesContractLogic garmentPreSalesContractLogic = new GarmentPreSalesContractLogic(identityService, dbContext);

            var azureImageFacadeMock = new Mock <IAzureImageFacade>();

            azureImageFacadeMock
            .Setup(s => s.DownloadImage(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync("[\"test\"]");
            azureImageFacadeMock
            .Setup(s => s.UploadMultipleImage(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <List <string> >(), It.IsAny <string>()))
            .ReturnsAsync("[\"test\"]");
            azureImageFacadeMock
            .Setup(s => s.RemoveMultipleImage(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.FromResult(0));

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IIdentityService)))
            .Returns(identityService);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(CostCalculationGarmentMaterialLogic)))
            .Returns(costCalculationGarmentMaterialLogic);

            CostCalculationGarmentLogic costCalculationGarmentLogic = new CostCalculationGarmentLogic(costCalculationGarmentMaterialLogic, serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(CostCalculationGarmentLogic)))
            .Returns(costCalculationGarmentLogic);
            CostCalculationGarmentFacade costCalculationGarmentFacade = new CostCalculationGarmentFacade(serviceProviderMock.Object, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ICostCalculationGarment)))
            .Returns(costCalculationGarmentFacade);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(GarmentPreSalesContractLogic)))
            .Returns(garmentPreSalesContractLogic);
            serviceProviderMock
            .Setup(x => x.GetService(typeof(IAzureImageFacade)))
            .Returns(azureImageFacadeMock.Object);

            var azureDocumentFacadeMock = new Mock <IAzureDocumentFacade>();

            azureDocumentFacadeMock
            .Setup(s => s.DownloadMultipleFiles(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(new List <string> {
                "[\"test\"]"
            });
            azureDocumentFacadeMock
            .Setup(s => s.UploadMultipleFile(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <List <string> >(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync("[\"test\"]");
            azureDocumentFacadeMock
            .Setup(s => s.RemoveMultipleFile(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(Task.FromResult(0));

            serviceProviderMock
            .Setup(x => x.GetService(typeof(IAzureDocumentFacade)))
            .Returns(azureDocumentFacadeMock.Object);

            ROGarmentSizeBreakdownDetailLogic roGarmentSizeBreakdownDetailLogic = new ROGarmentSizeBreakdownDetailLogic(serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ROGarmentSizeBreakdownDetailLogic)))
            .Returns(roGarmentSizeBreakdownDetailLogic);

            ROGarmentSizeBreakdownLogic roGarmentSizeBreakdownLogic = new ROGarmentSizeBreakdownLogic(serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ROGarmentSizeBreakdownLogic)))
            .Returns(roGarmentSizeBreakdownLogic);

            ROGarmentLogic roGarmentLogic = new ROGarmentLogic(serviceProviderMock.Object, identityService, dbContext);

            serviceProviderMock
            .Setup(x => x.GetService(typeof(ROGarmentLogic)))
            .Returns(roGarmentLogic);
            //var costCalculationMock = new Mock<ICostCalculationGarment>();
            //costCalculationMock
            //    .Setup(s => s.ReadByIdAsync(It.IsAny<int>()));

            return(serviceProviderMock);
        }
コード例 #18
0
 public SalesController(SalesDbContext context)
 {
     _dbContext = context;
 }
コード例 #19
0
 public ROGarmentLogic(IServiceProvider serviceProvider, IIdentityService identityService, SalesDbContext dbContext) : base(identityService, serviceProvider, dbContext)
 {
     this.roGarmentSizeBreakdownLogic       = serviceProvider.GetService <ROGarmentSizeBreakdownLogic>();
     this.roGarmentSizeBreakdownDetailLogic = serviceProvider.GetService <ROGarmentSizeBreakdownDetailLogic>();
     this.DbContext = dbContext;
 }
コード例 #20
0
 public ProductionOrderLogic(IServiceProvider serviceProvider, IIdentityService identityService, SalesDbContext dbContext) : base(identityService, serviceProvider, dbContext)
 {
     this.productionOrder_DetailLogic       = serviceProvider.GetService <ProductionOrder_DetailLogic>();
     this.productionOrder_LampStandardLogic = serviceProvider.GetService <ProductionOrder_LampStandardLogic>();
     this.productionOrder_RunWidthLogic     = serviceProvider.GetService <ProductionOrder_RunWidthLogic>();
 }
コード例 #21
0
 public DOStockLogic(IIdentityService IdentityService, SalesDbContext dbContext) : base(IdentityService, dbContext)
 {
 }
コード例 #22
0
 public CancelOrderHandler(SalesDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
コード例 #23
0
 public MySqlData(string password)
 {
     this.context = new SalesDbContext(string.Format(ConnectionString, password));
     this.repository = new MySqlLocalRepository(this.context);
 }
コード例 #24
0
 public SalesInvoiceLogic(IServiceProvider serviceProvider, IIdentityService identityService, SalesDbContext dbContext) : base(identityService, serviceProvider, dbContext)
 {
     this.salesInvoiceDetailLogic = serviceProvider.GetService <SalesInvoiceDetailLogic>();
     _dbContext = dbContext;
 }
コード例 #25
0
 public FinishingPrintingCostCalculationLogic(IIdentityService IdentityService, SalesDbContext dbContext) : base(IdentityService, dbContext)
 {
     _dbContext = dbContext;
 }
 public BudgetJobOrderDisplayFacade(IServiceProvider serviceProvider, SalesDbContext dbContext)
 {
     DbContext                  = dbContext;
     IdentityService            = serviceProvider.GetService <IdentityService>();
     budgetJobOrderDisplayLogic = serviceProvider.GetService <BudgetJobOrderDisplayLogic>();
 }
コード例 #27
0
        protected CostCalculationGarmentDataUtil DataUtil(CostCalculationGarmentFacade facade, SalesDbContext dbContext = null)
        {
            var serviceProvider = GetServiceProviderMock(dbContext).Object;

            GarmentPreSalesContractFacade   garmentPreSalesContractFacade   = new GarmentPreSalesContractFacade(serviceProvider, dbContext);
            GarmentPreSalesContractDataUtil garmentPreSalesContractDataUtil = new GarmentPreSalesContractDataUtil(garmentPreSalesContractFacade);

            CostCalculationGarmentDataUtil costCalculationGarmentDataUtil = new CostCalculationGarmentDataUtil(facade, garmentPreSalesContractDataUtil);

            return(costCalculationGarmentDataUtil);
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: Jimmyson/PHP-Sales
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetFullPath("..\\..\\..\\PHP.Sales.Web\\App_Data"));
            using (var ctx = new SalesDbContext())
            {
                ctx.Database.Delete();
                ctx.Database.CreateIfNotExists();

                //CREATE YOUR OBJECTS

                //CREATE THE PRODUCTS
                List <Product> prods = new List <Product>(new Product[] {
                    new Product()
                    {
                        Name  = "Panodol",
                        Price = 12.32m,
                        QTY   = 30
                    },
                    new Product()
                    {
                        Name  = "Nurofen",
                        Price = 6.32m,
                        QTY   = 40
                    },
                    new Product()
                    {
                        Name  = "Anti-Fungal",
                        Price = 7.29m,
                        QTY   = 10
                    },
                    new Product()
                    {
                        Name  = "Antibiotic",
                        Price = 8.99m,
                        QTY   = 5
                    },
                    new Product()
                    {
                        Name  = "Antihistermine",
                        Price = 18.02m,
                        QTY   = 10
                    },
                    new Product()
                    {
                        Name  = "Sunscreen",
                        Price = 3372.5m,
                        QTY   = 1000
                    },
                    new Product()
                    {
                        Name  = "Multivitamin 90",
                        Price = 112400.00m,
                        QTY   = 7500
                    },
                    new Product()
                    {
                        Name  = "Vitamin D",
                        QTY   = 1000.00m,
                        Price = 8990.00m,
                    },
                    new Product()
                    {
                        Name  = "HS Pain Killer",
                        QTY   = 10m,
                        Price = 8.99m,
                    },
                    new Product()
                    {
                        Name  = "Baby Paracetemol",
                        QTY   = 5.00m,
                        Price = 12.59m,
                    },
                    new Product()
                    {
                        Name  = "Cold and Flu 24",
                        QTY   = 4.00m,
                        Price = 7.29m,
                    },
                });

                foreach (Product p in prods)
                {
                    p.Update();
                    ProductLog.GenerateProductLog(ctx, p, p.QTY);
                }
                ctx.Products.AddRange(prods);

                //CREATE THE TRANSACTIONS
                //First Transaction and Sale
                var tran1 = new Transaction()
                {
                    PayMethod = PaymentType.VISA,
                    SaleTime  = DateTime.Now
                };

                var sale11 = new Sale()
                {
                    Product = prods[0],
                    QTY     = 4.00m,
                    Price   = 12.32m,
                    GST     = true,
                    Void    = false,
                };

                //Second Transaction and Sale
                var tran2 = new Transaction()
                {
                    PayMethod = PaymentType.CASH,
                    SaleTime  = DateTime.Now,
                };

                var sale21 = new Sale()
                {
                    Product = prods[1],
                    QTY     = 2.00m,
                    Price   = 6.32m,
                    GST     = true,
                    Void    = false,
                };

                var sale22 = new Sale()
                {
                    Product = prods[0],
                    QTY     = 3.00m,
                    Price   = 9.24m,
                    GST     = true,
                    Void    = false,
                };

                //Third Transaction and Sale
                var tran3 = new Transaction()
                {
                    PayMethod = PaymentType.MASTERCARD,
                    SaleTime  = DateTime.Now,
                };

                var sale31 = new Sale()
                {
                    Product = prods[2],
                    QTY     = 1.00m,
                    Price   = 7.29m,
                    GST     = true,
                    Void    = false,
                };

                var sale32 = new Sale()
                {
                    Product = prods[3],
                    QTY     = 1.00m,
                    Price   = 8.99m,
                    GST     = false,
                    Void    = false,
                };

                var sale33 = new Sale()
                {
                    Product = prods[4],
                    QTY     = 2.00m,
                    Price   = 18.02m,
                    GST     = true,
                    Void    = false,
                };

                //Fourth Transaction and Sale (Large Quantities)
                var tran4 = new Transaction()
                {
                    PayMethod = PaymentType.CASH,
                    SaleTime  = DateTime.Now,
                };

                var sale41 = new Sale()
                {
                    Product = prods[5],
                    QTY     = 250.00m,
                    Price   = 3372.5m,
                    GST     = true,
                    Void    = false,
                };

                var sale42 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 5000.00m,
                    Price   = 112400.00m,
                    GST     = true,
                    Void    = false,
                };

                var sale43 = new Sale()
                {
                    Product = prods[7],
                    QTY     = 1000.00m,
                    Price   = 8990.00m,
                    GST     = true,
                    Void    = false,
                };

                //Fifth Transaction and Sale (One of Everything)
                var tran5 = new Transaction()
                {
                    PayMethod = PaymentType.CASH,
                    SaleTime  = DateTime.Now,
                };

                var sale51 = new Sale()
                {
                    Product = prods[0],
                    QTY     = 1.00m,
                    Price   = 3.08m,
                    GST     = true,
                    Void    = false,
                };

                var sale52 = new Sale()
                {
                    Product = prods[1],
                    QTY     = 1.00m,
                    Price   = 3.16m,
                    GST     = true,
                    Void    = false,
                };

                var sale53 = new Sale()
                {
                    Product = prods[2],
                    QTY     = 1.00m,
                    Price   = 9.02m,
                    GST     = true,
                    Void    = false,
                };

                var sale54 = new Sale()
                {
                    Product = prods[5],
                    QTY     = 1.00m,
                    Price   = 13.49m,
                    GST     = true,
                    Void    = false,
                };

                var sale55 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 1.00m,
                    Price   = 22.48m,
                    GST     = true,
                    Void    = false,
                };

                var sale56 = new Sale()
                {
                    Product = prods[7],
                    QTY     = 10.00m,
                    Price   = 8.99m,
                    GST     = true,
                    Void    = false,
                };

                var sale57 = new Sale()
                {
                    Product = prods[4],
                    QTY     = 1.00m,
                    Price   = 8.99m,
                    GST     = false,
                    Void    = false,
                };

                var sale58 = new Sale()
                {
                    Product = prods[8],
                    QTY     = 1.00m,
                    Price   = 8.99m,
                    GST     = false,
                    Void    = false,
                };

                var sale59 = new Sale()
                {
                    Product = prods[9],
                    QTY     = 1.00m,
                    Price   = 12.59m,
                    GST     = true,
                    Void    = false,
                };

                var sale510 = new Sale()
                {
                    Product = prods[2],
                    QTY     = 1.00m,
                    Price   = 7.29m,
                    GST     = true,
                    Void    = false,
                };

                var sale511 = new Sale()
                {
                    Product = prods[10],
                    QTY     = 1.00m,
                    Price   = 7.29m,
                    GST     = true,
                    Void    = false,
                };

                //Sixth Sale and Trnasaction
                var tran6 = new Transaction()
                {
                    PayMethod = PaymentType.VISA,
                    SaleTime  = DateTime.Now,
                };

                var sale61 = new Sale()
                {
                    Product = prods[10],
                    QTY     = 1.00m,
                    Price   = 7.29m,
                    GST     = true,
                    Void    = false,
                };

                var sale62 = new Sale()
                {
                    Product = prods[8],
                    QTY     = 1.00m,
                    Price   = 8.99m,
                    GST     = false,
                    Void    = false,
                };

                var sale63 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 1.00m,
                    Price   = 22.48m,
                    GST     = true,
                    Void    = false,
                };

                //Seventh Sale and Transaction (Same product sold multiple times)
                var tran7 = new Transaction()
                {
                    PayMethod = PaymentType.MASTERCARD,
                    SaleTime  = DateTime.Now,
                };

                var sale71 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 10.00m,
                    Price   = 224.80m,
                    GST     = true,
                    Void    = false,
                };

                var sale72 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 1.00m,
                    Price   = 22.48m,
                    GST     = true,
                    Void    = false,
                };

                var sale73 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 1.00m,
                    Price   = 22.48m,
                    GST     = true,
                    Void    = false,
                };

                var sale74 = new Sale()
                {
                    Product = prods[10],
                    QTY     = 1.00m,
                    Price   = 7.29m,
                    GST     = true,
                    Void    = false,
                };

                var sale75 = new Sale()
                {
                    Product = prods[6],
                    QTY     = 1.00m,
                    Price   = 22.48m,
                    GST     = true,
                    Void    = false,
                };

                //Update Sale 7
                sale71.Update();
                sale72.Update();
                sale73.Update();
                sale74.Update();
                sale75.Update();

                tran7.Sales.Add(sale71);
                tran7.Sales.Add(sale72);
                tran7.Sales.Add(sale73);
                tran7.Sales.Add(sale74);
                tran7.Sales.Add(sale75);

                foreach (Sale s in tran7.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran7.Update();

                ctx.Transactions.Add(tran7);

                //Update Sale 6
                sale61.Update();
                sale62.Update();
                sale63.Update();

                tran6.Sales.Add(sale61);
                tran6.Sales.Add(sale62);
                tran6.Sales.Add(sale63);

                foreach (Sale s in tran6.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran6.Update();

                ctx.Transactions.Add(tran6);

                //Update Sale 5
                sale51.Update();
                sale52.Update();
                sale53.Update();
                sale54.Update();
                sale55.Update();
                sale56.Update();
                sale57.Update();
                sale58.Update();
                sale59.Update();
                sale510.Update();
                sale511.Update();

                tran5.Sales.Add(sale51);
                tran5.Sales.Add(sale52);
                tran5.Sales.Add(sale53);
                tran5.Sales.Add(sale54);
                tran5.Sales.Add(sale55);
                tran5.Sales.Add(sale56);
                tran5.Sales.Add(sale57);
                tran5.Sales.Add(sale58);
                tran5.Sales.Add(sale59);
                tran5.Sales.Add(sale510);
                tran5.Sales.Add(sale511);

                foreach (Sale s in tran5.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran5.Update();

                ctx.Transactions.Add(tran5);

                //Update Sale 4
                sale41.Update();
                sale42.Update();
                sale43.Update();

                tran4.Sales.Add(sale41);
                tran4.Sales.Add(sale42);
                tran4.Sales.Add(sale43);

                foreach (Sale s in tran4.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran4.Update();

                ctx.Transactions.Add(tran4);

                //Update Sale 3
                sale31.Update();
                sale32.Update();
                sale33.Update();

                tran3.Sales.Add(sale31);
                tran3.Sales.Add(sale32);
                tran3.Sales.Add(sale33);

                foreach (Sale s in tran3.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran3.Update();

                ctx.Transactions.Add(tran3);

                //Update Sale 2
                sale21.Update();
                sale22.Update();

                tran2.Sales.Add(sale21);
                tran2.Sales.Add(sale22);

                foreach (Sale s in tran2.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran2.Update();

                ctx.Transactions.Add(tran2);

                //Update Sale 1
                sale11.Update();

                tran1.Sales.Add(sale11);

                foreach (Sale s in tran1.Sales)
                {
                    ProductLog.GenerateSaleLog(ctx, s.Product, s.QTY);
                }

                tran1.Update();

                ctx.Transactions.Add(tran1);

                //ADD REPORT
                List <Report> reports = new List <Report>()
                {
                    new Report()
                    {
                        Name    = "Test Report",
                        Product = prods[0],
                        Start   = DateTime.Now,
                        End     = DateTime.Now.AddDays(1)
                    },
                    new Report()
                    {
                        Name    = "Test Weekly Report",
                        Product = prods[2],
                        Start   = DateTime.Now.AddDays(-7),
                        End     = DateTime.Now.AddDays(-1)
                    },
                    new Report()
                    {
                        Name    = "Test Monthly Report",
                        Product = prods[2],
                        Start   = DateTime.Now.AddMonths(-1),
                        End     = DateTime.Now.AddDays(-1)
                    }
                };

                foreach (var r in reports)
                {
                    r.Update();
                }

                ctx.Reports.AddRange(reports);

                //ADD STOCK SNAPSHOT

                List <Stock> snapshots = new List <Stock>()
                {
                    /*new Stock()
                     * {
                     *  Product = prods[0],
                     *  TimeStamp = DateTime.Now.Date,
                     *  QTY = 30
                     * },
                     * new Stock()
                     * {
                     *  Product = prods[0],
                     *  TimeStamp = DateTime.Now.AddDays(-1).Date,
                     *  QTY = 37
                     * },
                     * new Stock()
                     * {
                     *  Product = prods[1],
                     *  TimeStamp = DateTime.Now.Date,
                     *  QTY = 38
                     * },
                     * new Stock()
                     * {
                     *  Product = prods[1],
                     *  TimeStamp = DateTime.Now.AddDays(-1).Date,
                     *  QTY = 42
                     * },*/
                };

                DateTime check = DateTime.Now.AddDays(-40).Date;
                Random   rand  = new Random();

                do
                {
                    foreach (var p in prods)
                    {
                        Stock stock = new Stock()
                        {
                            Product   = p,
                            TimeStamp = check.Date,
                            QTY       = (decimal)rand.NextDouble() * rand.Next(150)
                        };
                        stock.Update();
                        snapshots.Add(stock);

                        int i = rand.Next(6);
                        for (var j = 0; j < i; j++)
                        {
                            Transaction t = new Transaction()
                            {
                                PayMethod = (PaymentType)rand.Next(3),
                            };

                            int k = rand.Next(10);
                            for (var l = 0; l < k; l++)
                            {
                                Sale s = new Sale()
                                {
                                    Product = prods[rand.Next(prods.Count)],
                                    QTY     = (decimal)rand.NextDouble() * rand.Next(10),
                                    GST     = (rand.NextDouble() > 0.5) ? true : false,
                                    Void    = false
                                };
                                s.Price = s.Product.Price;
                                s.Update();

                                Log log = new Log()
                                {
                                    ProductID = s.Product.ID,
                                    QTY       = -s.QTY,
                                    TimeStamp = t.SaleTime
                                };
                                log.Update();
                                ctx.Logs.Add(log);

                                t.Sales.Add(s);
                            }
                            t.Update();
                            t.SaleTime = check.AddMinutes(rand.Next(60 * 24));
                            ctx.Transactions.Add(t);
                        }
                    }
                    check = check.AddDays(+1);
                } while (check.Date <= DateTime.Now.Date);

                ctx.StockSnapshot.AddRange(snapshots);


                // Save Transaction Database
                ctx.SaveChanges();
            }
        }
コード例 #29
0
 public FinishingPrintingCostCalculationFacade(IServiceProvider serviceProvider, SalesDbContext dbContext)
 {
     DbContext     = dbContext;
     DbSet         = DbContext.Set <FinishingPrintingCostCalculationModel>();
     ChemicalDBSet = DbContext.Set <FinishingPrintingCostCalculationChemicalModel>();
     finishingPrintingCostCalculationLogic = serviceProvider.GetService <FinishingPrintingCostCalculationLogic>();
     AzureImageFacade = serviceProvider.GetService <IAzureImageFacade>();
 }
 public TablesFromSnapshot(SalesDbContext dbContext) => _dbContext = dbContext;
コード例 #31
0
 public FinishingPrintingSalesContractLogic(FinishingPrintingSalesContractDetailLogic finishingPrintingSalesContractDetailLogic, IServiceProvider serviceProvider, IIdentityService identityService, SalesDbContext dbContext) : base(identityService, serviceProvider, dbContext)
 {
     this.FinishingPrintingSalesContractDetailLogic = finishingPrintingSalesContractDetailLogic;
 }
コード例 #32
0
 public MySqlLocalRepository(SalesDbContext context)
 {
     this.context = context;
 }