コード例 #1
0
ファイル: HomeController.cs プロジェクト: talajiam/Hackathon
        public ActionResult Index(FAAS.Models.HeaderModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            int ItemsCount = 0;
            double TotalBill = 0;
            Entities.UserOrder Order = new Entities.UserOrder();
            Entities.Checkout chekout = new Entities.Checkout();
            CheckoutModel chekoutmodel = new CheckoutModel();
            List<ProductItem> proList = new List<ProductItem>();
            try
            {
                foreach (var prodct in model.productItems)
                {
                    if (prodct.IsSelected || prodct.Qty > 0)
                    {
                        ProductItem confirmedProduct = new ProductItem();
                        ItemsCount++;
                        TotalBill += prodct.Price * prodct.Qty;
                        confirmedProduct.ProductId = prodct.ProductId;
                        confirmedProduct.Qty = prodct.Qty;
                        confirmedProduct.Price = prodct.Price;
                        confirmedProduct.Name = prodct.Name;
                        confirmedProduct.Calories = prodct.Calories;
                        confirmedProduct.ImageUrl = prodct.ImageUrl;
                        proList.Add(confirmedProduct);
                    }
                }

                chekoutmodel.TotalPrice = TotalBill;
                chekoutmodel.TotalItemQty = ItemsCount;
                chekoutmodel.ProdcutItems = proList;

                // Get Customer Address Detail Based on CustID

                CustomerController custReg = new CustomerController();
                List<Customer> customerList = custReg.Get(model.CustmorID).ToList(); chekoutmodel.CustmorID = model.CustmorID;
                if (customerList.Count > 0)
                {
                    chekoutmodel.CustomerName = customerList[0].CustomerName; //address.CustomerName;
                    chekoutmodel.DeliveryLocationCode = customerList[0].Postcode; //address.Postcode;
                    chekoutmodel.DeliveryAddress = customerList[0].Address;//address.Address;
                    chekoutmodel.MobileNo = customerList[0].MobileNo.ToString(); //address.MobileNo;

                }
                else
                {
                    Customer address = new Customer();
                    chekoutmodel.CustomerName = "Uday"; //address.CustomerName;
                    chekoutmodel.DeliveryLocationCode = "AL74FG"; //address.Postcode;
                    chekoutmodel.DeliveryAddress = "House No 10 ,Heartford";//address.Address;
                    chekoutmodel.MobileNo = "9739027030"; //address.MobileNo;
                }
                chekoutmodel.DeliveryCharge = 5;
                chekoutmodel.DeliveryStartDate = DateTime.Today.AddHours(12);
                chekoutmodel.DeliveryEndDate = DateTime.Today.AddHours(13);
            }

            catch (Exception ex)
            {
            }
            chekout.ItemQty = ItemsCount;
            chekout.TotalPrice = TotalBill;

            return View("Payment", chekoutmodel);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: talajiam/Hackathon
        public ActionResult Payment(FAAS.Models.CheckoutModel model)
        {
            int ItemsCount = 0;
            double TotalBill = 0;

            Entities.Checkout chekout = new Entities.Checkout();

            chekout.CustmorID = 1;
            try
            {

                //Make Confirm Call

                OrderController placeOrder = new OrderController();
                TescoFAAS.Entities.Order order = new TescoFAAS.Entities.Order();

                order.CustomerId = model.CustmorID;
                order.CustomerName = model.CustomerName;
                order.DeliveryAddress = model.DeliveryAddress;
                order.DeliveryCharge = model.DeliveryCharge;
                order.DeliveryLocationCode = model.DeliveryLocationCode;
                order.DeliveryStartDate = model.DeliveryStartDate;
                order.DeliveryEndDate = model.DeliveryEndDate;
                //order.Id = RandomNumber(50000,60000);
                order.Items = model.ProdcutItems;
                order.MobileNo = model.MobileNo;
                order.TotalItemCount = model.TotalItemQty;
                order.TotalPrice = model.TotalPrice;
                order.Status = TescoFAAS.Entities.OrderStatus.Confirm;
                order.WebcutoffDateTime = DateTime.Today.AddHours(8);

                int orderID = placeOrder.Post(order);
                model.OrderId = orderID;
                chekout.OrderId = orderID;
                //foreach (var prodct in model.productItems)
                //{
                //    if (prodct.IsSelected)
                //    {
                //        ItemsCount++;
                //        TotalBill += prodct.Price * prodct.Qty;
                //    }
                //}
            }
            catch (Exception ex)
            {

            }

            chekout.ItemQty = ItemsCount;
            chekout.TotalPrice = TotalBill;

            return View("ConfirmOrder", model);
        }