public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Order order = mySQLOrderService.Detail(id); var lstFlowersModel = new List <FlowersInOrderModel>(); foreach (var item in order.OrderDetails) { var flowerModel = new FlowersInOrderModel() { Id = item.Id, FlowerName = mySQLFlowerService.Detail(item.FlowerCode).Name, ImageUrl = mySQLFlowerService.Detail(item.FlowerCode).FlowerImages.OrderByDescending(s => s.CreatedAt).FirstOrDefault().ImageUrl, Quantity = item.Quantity, TotalPricePerFlower = item.Quantity * item.UnitPrice }; lstFlowersModel.Add(flowerModel); } ViewBag.ListFlowersInOrder = lstFlowersModel; if (order == null || order.IsDeleted()) { return(HttpNotFound()); } return(View(order)); }
public ActionResult DisplayCartAfterCreateOrder(int?orderId) { var order = db.Orders.Find(orderId); if (order == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound, "Not Found")); } //ViewBag.ListFlowers = mySQLFlowerService.GetList().Where(s => order.OrderDetails.Select(p => p.FlowerCode).Contains(s.Code)).ToList(); var lstFlowersModel = new List <FlowersInOrderModel>(); foreach (var item in order.OrderDetails) { var flowerModel = new FlowersInOrderModel() { FlowerName = mySQLFlowerService.Detail(item.FlowerCode).Name, ImageUrl = mySQLFlowerService.Detail(item.FlowerCode).FlowerImages.OrderByDescending(s => s.CreatedAt).FirstOrDefault().ImageUrl, Quantity = item.Quantity, TotalPricePerFlower = item.Quantity * item.UnitPrice }; lstFlowersModel.Add(flowerModel); } ViewBag.ListFlowersInOrder = lstFlowersModel; // Paypal //bool useSandbox = Convert.ToBoolean(ConfigurationManager.AppSettings["IsSandbox"]); //var paypal = new PayPalModel(useSandbox); ////Session[CurrentOrder] = order; //paypal.item_name = "Order of " + userService.GetCurrentUserName(); //paypal.amount = order.TotalPrice.ToString(); //var strParam = orderId + "," + userService.GetCurrentUserName() + "," + userService.GetCurrentUserId(); //paypal.notify_url = paypal.notify_url + "?strParam=" + strParam; //paypal.@return = paypal.@return + "?orderId=" + orderId; //paypal.cancel_return = paypal.cancel_return + "?orderId=" + orderId; //ViewBag.Paypal = paypal; return(View(order)); }