Пример #1
0
        private async Task UrunSatisTipiAsync(KahveAkademisiContext context)
        {
            AppUser admin = await _userManager.FindByNameAsync("05379226233");

            for (int i = 0; i < products.Count; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    double     adet       = 0;
                    AmountType amountType = new AmountType();
                    switch (j + 1)
                    {
                    case 1:
                        amountType = AmountType.Piece;
                        adet       = adetler[FakeData.NumberData.GetNumber(0, adetler.Count() - 1)];
                        break;

                    case 2:
                        amountType = AmountType.Weight;
                        adet       = kglar[FakeData.NumberData.GetNumber(0, kglar.Count() - 1)];
                        break;

                    case 3:
                        amountType = AmountType.Box;
                        adet       = kglar[FakeData.NumberData.GetNumber(0, kasalar.Count() - 1)];
                        break;
                    }

                    ProductAmountType productAmountType = new ProductAmountType()
                    {
                        AmountType   = amountType,
                        CreateUserId = admin.Id,
                        Product      = products[i],
                        UpdateUserId = admin.Id,
                        Price        = FakeData.NumberData.GetNumber(1, 15),
                        Choice       = amountType == AmountType.Piece ? true : false,
                        Weight       = FakeData.NumberData.GetNumber(1, 20),
                        Stock        = FakeData.NumberData.GetNumber(5, 100)
                    };

                    context.ProductAmountTypes.Add(productAmountType);
                }
            }

            context.SaveChanges();
            products = context.Products.Include(x => x.ProductAmountTypes).ToList();
        }
Пример #2
0
        private void SiparisEkle(KahveAkademisiContext context, int adet, int kacUrun)
        {
            for (int i = 0; i < appUsers.Count; i++)
            {
                for (int t = 0; t < adet; t++)
                {
                    double genelToplam = 0;

                    Order order = new Order()
                    {
                        UserId      = appUsers[i].Id,
                        OrderDate   = DateTime.Now,
                        OrderStatus = t % 2 == 0 ? OrderStatus.Approved : OrderStatus.Canceled,
                        UserAdress  = userAdresses.Where(x => x.UserId == appUsers[i].Id).FirstOrDefault(),
                    };

                    for (int j = 0; j < kacUrun; j++)
                    {
                        int productIndex = FakeData.NumberData.GetNumber(0, products.Count - 1);
                        int quantity     = FakeData.NumberData.GetNumber(1, 30);
                        ProductAmountType productAmountType = products[productIndex].ProductAmountTypes[FakeData.NumberData.GetNumber(0, products[productIndex].ProductAmountTypes.Count - 1)];
                        OrderDetail       orderDetail       = new OrderDetail()
                        {
                            Order             = order,
                            OrderStatus       = j % 2 == 0 ? OrderStatus.Active : OrderStatus.Canceled,
                            ProductAmountType = productAmountType,
                            Quantity          = quantity,
                            TotalPrice        = productAmountType.Price * quantity
                        };


                        genelToplam = orderDetail.TotalPrice + genelToplam;

                        order.OrderDetails.Add(orderDetail);
                    }

                    order.TotalPrice = genelToplam;

                    context.Orders.Add(order);
                }
            }

            context.SaveChanges();
        }
Пример #3
0
        private void buttonekle_Click(object sender, EventArgs e)
        {
            Product p = new Product();

            p.UrunBarkod = textBoxbarkod.Text;
            p.UrunAdi    = textBoxurun_adi.Text;
            p.UrunMiktar = Convert.ToDouble(numericUpDownurun_miktar.Value);
            p.KDVOran    = int.Parse(comboBoxKDV.SelectedItem.ToString());
            p.StockAdeti = Convert.ToInt32(numericUpDowstok_adeti.Value);

            Category c = (Category)comboBoxurun_kategori.SelectedItem;

            p.KategoriID = c.ID;


            ProductAmountType pat = (ProductAmountType)comboBoxurun_miktar_türü.SelectedItem;

            p.UrunMiktarTuruID = pat.ID;
            using (StokTakibiDBContext context = new StokTakibiDBContext())
            {
                context.Product.Add(p);
                context.SaveChanges();
            }
        }