Ejemplo n.º 1
0
        public ActionResult DetailList()
        { // Sepet Boş iken hata alıyoruz
            Order   sepetim    = (Order)Session["Order"];
            decimal?TotalPrice = 0;

            if (sepetim != null)
            {
                OrderRep or = new OrderRep();
                if (sepetim.OrderDetails != null)
                {
                    foreach (OrderDetail item in sepetim.OrderDetails)
                    {
                        TotalPrice += item.Price;
                    }
                    sepetim.TotalPrice = TotalPrice;
                    or.Update(sepetim);
                }

                else
                {
                    sepetim.TotalPrice = 0;
                    or.Update(sepetim);
                }
                return(View(sepetim.OrderDetails));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Pay(Invoice model, List <string> PaymentTypes)
        {
            model.PaymentDate = DateTime.Now;
            foreach (string item in PaymentTypes)
            {
                int PaymentId = Convert.ToInt32(item);
                model.PaymentTypeId = PaymentId;
            }
            model.OrderId = ((Order)Session["Order"]).OrderId;
            InvoiceRep ip = new InvoiceRep();

            if (ip.Insert(model).IsSuccessed)
            {
                Order ord = (Order)Session["Order"];
                if (Request.Cookies["id"] != null)
                {
                    HttpCookie aCookie = Request.Cookies["id"];
                    int        id      = Convert.ToInt32(Server.HtmlEncode(aCookie.Value));
                    ord.MemberId = id;
                }
                OrderRep ordrep = new OrderRep();
                ord.IsPay = true;
                ordrep.Update(ord);
                return(RedirectToAction("PaySucces", "Payment"));
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 3
0
        public void AcceptOrder(int orderId)
        {
            var order      = OrderRep.Get(orderId);
            var prodAccept = order.Products;
            var warehouse  = LocationRep.Get(order.LocationId);

            foreach (var item in prodAccept)
            {
                var prod = warehouse.Products.Where(p => p.Product.ProductId == item.Product.ProductId).FirstOrDefault();
                if (prod != null)
                {
                    prod.Value         += item.Value;
                    prod.TotalQuantity += (decimal)item.Value;
                    prod.TotalPrice    += item.Price * (decimal)item.Value;
                    prod.Price          = prod.TotalPrice / prod.TotalQuantity;
                }
                else
                {
                    warehouse.Products.Add
                    (
                        new ProductStorage
                    {
                        Product = ProductRep.Get(item.Product.ProductId),
                        Value   = item.Value,
                        Price   = item.Price
                    });
                }
            }
            order.Accept     = true;
            order.AcceptDate = DateTime.Today;
        }
Ejemplo n.º 4
0
        public ActionResult DetailList()
        {
            Order    sepetim    = (Order)Session["Order"];
            decimal? TotalPrice = 0;
            OrderRep or         = new OrderRep();

            if (sepetim != null)
            {
                if (sepetim.OrderDetails != null)
                {
                    foreach (OrderDetail item in sepetim.OrderDetails)
                    {
                        TotalPrice += item.Price;
                    }
                    sepetim.TotalPrice = TotalPrice;
                    or.Update(sepetim);
                }
                else
                {
                    sepetim.TotalPrice = 0;
                    or.Update(sepetim);
                }
                if (sepetim == null)
                {
                    return(RedirectToAction("ListAllProduct", "Home"));
                }
                else
                {
                    return(View(sepetim.OrderDetails));
                }
            }
            return(RedirectToAction("DetailList", "Order"));
        }
        public ActionResult Pay(Invoice model, List <string> PaymentTypes)
        {
            model.PaymentDate = DateTime.Now;
            foreach (string item in PaymentTypes)
            {
                int PaymentId = Convert.ToInt32(item);
                model.PaymentTypeId = PaymentId;
            }
            model.OrderId = ((Order)Session["Order"]).OrderId;
            InvoiceRepository ip = new InvoiceRepository();

            if (ip.Insert(model).IsSucceeded)
            {
                Order    ord    = (Order)Session["Order"];
                OrderRep ordrep = new OrderRep();
                ord.IsPay = true;
                ordrep.Update(ord);
                Session.Abandon();
                return(RedirectToAction("Thanks", "Home"));
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 6
0
        public ActionResult Pay(Invoice model, List <string> PaymentTypes)
        {
            model.PaymentDate = DateTime.Now;
            foreach (string item in PaymentTypes)
            {
                int PaymentId = Convert.ToInt32(item);
                model.PaymentTypeId = PaymentId;
            }
            model.OrderId = ((Order)Session["Order"]).OrderId;
            InvoiceRep ip = new InvoiceRep();

            if (ip.Insert(model).IsSuccessed)
            {
                List <Product> proList   = new List <Product>();
                Order          ord       = (Order)Session["Order"];
                OrderRep       ordrep    = new OrderRep();
                OrderDetailRep ordDetRep = new OrderDetailRep();
                ProductRep     proRep    = new ProductRep();
                Result <List <OrderDetail> > ordDetRes = ordDetRep.GetListByOrdId((int)model.OrderId);
                foreach (OrderDetail item in ordDetRes.ProcessResult)
                {
                    Product pr = proRep.GetObjById(item.ProductId).ProcessResult;
                    if (pr.Stock != null)
                    {
                        if (pr.Stock < item.Quantity)
                        {
                            string msg = "Yeterli sayida stok yok";
                            return(RedirectToAction("DetailList", "Order", new { msg = msg }));
                        }
                        else
                        {
                            pr.Stock -= item.Quantity;
                            proList.Add(pr);
                        }
                    }
                }
                Member mem = (Member)Session["UserID"];
                if (mem != null)
                {
                    ord.MemberId = mem.UserId;
                    ord.IsPay    = true;
                    ordrep.Update(ord);
                    foreach (Product item in proList)
                    {
                        proRep.Update(item);
                    }
                    Session["Order"] = null;
                    return(RedirectToAction("LatestOrders", "Home"));
                }
                else
                {
                    return(RedirectToAction("SignIn", "Home"));
                }
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 7
0
        public void CreateOrder(IEnumerable <ProductOrdered> products, int supplierID, int warehouseID)
        {
            Order order = new Order();

            order.SupplierId = supplierID;
            order.LocationId = warehouseID;
            products         = products.Where(x => x.Value != 0);
            foreach (var product in products)
            {
                order.Products.Add(new ProductOrdered
                {
                    ProductId = product.ProductId,
                    Value     = product.Value,
                    Price     = product.Price
                });
            }
            OrderRep.Add(order);
            context.SaveChanges();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            serialize(); //serialize data from Data class

            deserialize();



            Functionality functionality = new Functionality();

            Console.WriteLine("welcome to the store application");
            bool choice = false;

            while (!choice)
            {
                Console.WriteLine("Press:\n 1 to add new customer\n 2 to place an order\n 3 to search a customer" +
                                  "\n 4 to quit the store system");
                Console.WriteLine("-------------------------------------------------");
                string option = Console.ReadLine();
                int    num    = 0;


                try
                {
                    num = int.Parse(option);
                }
                catch (FormatException)
                {
                    Console.WriteLine("Please try again. Attempted to use wrong input character.");
                    Console.WriteLine("Press numbers 1-4 to make your selection");
                    Console.WriteLine("--------------------------------------------------");
                }
                finally
                {
                    switch (num)
                    {
                    case 1:

                        CustomerRepository.Add();


                        break;

                    case 2:
                        OrderRep.addOrder();

                        break;

                    case 3:

                        CustomerRepository.searchCustomer();
                        break;


                    case 4:
                        choice = true;         //quiting from the store application
                        break;

                    default:
                        Console.WriteLine("Please try again. Attempted to use wrong input character.");
                        Console.WriteLine("Press numbers 1-4 to make your selection");
                        break;
                    }
                }
            }
        }
Ejemplo n.º 9
0
 static void Main(string[] args)
 {
     OrderContext context    = new OrderContext();
     OrderRep     repository = new OrderRep(context);
 }
Ejemplo n.º 10
0
 //Phương thức khởi tạo
 public OrderSvc()
 {
     _rep = new OrderRep(); //Truyền vào giá trị
 }
Ejemplo n.º 11
0
 public OrderSvc()
 {
     orderRep = new OrderRep();
 }