Exemplo n.º 1
0
        public ActionResult ConfirmOrder(int orderId)
        {
            var order               = railwayService.GetOrder(orderId);
            var orderPassenger      = order.OrderPassengers.First();
            var orderPassengersData = new List <ConfirmOrderViewModel.PassengerData>
            {
                new ConfirmOrderViewModel.PassengerData
                {
                    FirstName        = orderPassenger.Passenger.FirstName,
                    LastName         = orderPassenger.Passenger.LastName,
                    DocumentTypeName = orderPassenger.Passenger.IdentificationType.Name,
                    DocumentNumber   = orderPassenger.Passenger.IdentificationNumber,
                    SeatIndex        = orderPassenger.SeatIndex,
                    CarIndex         = orderPassenger.Car.CarIndex
                }
            };

            var viewModel = new ConfirmOrderViewModel
            {
                OrderId                    = order.OrderId,
                OrderDate                  = order.OrderDate,
                TripStartDate              = order.TripStartDate,
                TripDestinationDate        = order.TripDestinationDate,
                TrainNumber                = order.TrainNumber,
                TotalCost                  = order.TotalCost,
                TripStartStationName       = order.TripStartStation.StationName,
                TripDestinationStationName = order.TripDestinationStation.StationName,
                OrderPassengers            = orderPassengersData,
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> ConfirmOrder(ConfirmOrderViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = await GetCurrentUser();

                if (model.Answer.Contains("Ja") || model.Answer.Contains("ja"))
                {
                    // Network stuff

                    if (!(System.IO.File.Exists($@"wwwroot\data\{user.Email}.txt")))
                    {
                        _network = new Network(_numInputParameters, _hiddenNeurons, _numOutputParameters);
                    }

                    _network = ImportHelper.ImportNetwork(user.Email);

                    if (_network == null)
                    {
                        _logger.LogError("Something went wrong while importing the network");
                    }

                    _numInputParameters  = _network.InputLayer.Count;
                    _hiddenNeurons       = new int[_network.HiddenLayers.Count];
                    _numOutputParameters = _network.OutputLayer.Count;

                    var v = ParseIngredients(model.OriginalOrder);

                    var newDatasets = new List <DataSet>();

                    double[] expectedResult = new double[] { 1 };
                    newDatasets.Add(new DataSet(v.Select(Convert.ToDouble).ToArray(), expectedResult));
                    _dataSets = newDatasets;

                    for (int i = 0; i < 100; i++)
                    {
                        _network.Train(newDatasets, 1);
                    }

                    ExportHelper.ExportNetwork(_network, user.Email);

                    var sandwich = new Order {
                        Email = user.Email, OrderLine = ConvertIntToString(v), DateTime = DateTime.Now
                    };
                    _dbContext.Orders.Add(sandwich);
                    _dbContext.SaveChanges();

                    return(Redirect("Goodbye"));
                }
                else
                {
                    if (model.OriginalOrder.Contains("suggestie"))
                    {
                        return(Redirect("Suggestion"));
                    }
                }
            }
            return(Redirect("Index"));
        }
Exemplo n.º 3
0
        public IActionResult ConfirmOrder(int ticketId)
        {
            ConfirmOrderViewModel confirmOrderVM = new ConfirmOrderViewModel();

            confirmOrderVM.Ticket = this.motoGpContext.Tickets.Where(t => t.TicketID == ticketId).SingleOrDefault();
            confirmOrderVM.Race   = this.motoGpContext.Races.Where(r => r.RaceID == confirmOrderVM.Ticket.RaceID).Single();;
            return(View(confirmOrderVM));
        }
        public ActionResult ConfirmShoppingCart()
        {
            string       userId      = User.Identity.GetUserId();
            ShoppingCart sessionCart = GetCartFromSession(userId);

            // PayGate
            sessionCart.Order.PaymentOption = 2;

            ConfirmOrderViewModel model = new ConfirmOrderViewModel(sessionCart);

            return(View("ConfirmShoppingCart", model));
        }
Exemplo n.º 5
0
        public IActionResult ConfirmOrder(ConfirmOrderViewModel confOrdVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(confOrdVM));
            }

            Order closingOrder = _unitOfWork.Orders.GetItem(confOrdVM.OrderID);

            closingOrder.StatusID     = (int)Statuses.InProgress;
            closingOrder.ShipmentDate = confOrdVM.ShipmentDate;
            _unitOfWork.SaveChanges();
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 6
0
        public ActionResult ConfirmOrder()
        {
            ConfirmOrderViewModel model = new ConfirmOrderViewModel();

            var cartItemsCookie = Request.Cookies["cartItems"];

            if (cartItemsCookie != null && !string.IsNullOrEmpty(cartItemsCookie.Value))
            {
                model.ProductIDs = cartItemsCookie.Value.Split('-').Select(x => int.Parse(x)).ToList();

                if (model.ProductIDs.Count > 0)
                {
                    model.Products = ProductsService.Instance.GetProductsByIDs(model.ProductIDs.Distinct().ToList());
                }
            }

            return(PartialView("_ConfirmOrder", model));
        }
Exemplo n.º 7
0
 public ActionResult ConfirmOrder(ConfirmOrderViewModel model)
 {
     if (ModelState.IsValid)
     {
         string subjet = "";
         if (model.Type == 0)  //兑换
         {
             subjet = "兑换订单";
         }
         if (model.Type == 1)  //租借
         {
             subjet = "租借订单";
         }
         string submit = Com.Cos.Common.AlipayHelper.BuildRequest(_userId.ToString(), model.Money, subjet, model.Id.ToString(), model.Address, model.Deposit, model.Method);
         return(Content(submit, "text/html"));
     }
     return(View("ConfirmOrder", model));
 }
Exemplo n.º 8
0
        public JsonResult SubmitOrder(ConfirmOrderViewModel confirmOrderViewModel)
        {
            var orderModel = new OrderModel
            {
                OrderId      = OrderService.GetNewOrderId(),
                UserId       = this.UserInfo.UserId,
                ProductId    = confirmOrderViewModel.Product.Id,
                Price        = confirmOrderViewModel.Product.Price,
                ProductCount = confirmOrderViewModel.Count,
                Status       = OrderStatus.Init.GetHashCode(),
                PayType      = 0,
                CreateTime   = DateTime.Now
            };
            var data   = OrderService.SubmitOrder(orderModel);
            var result = new JsonResult();

            result.Data = data;
            return(result);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 确认订单
        /// </summary>
        /// <returns></returns>
        public ActionResult Order(int?productId)
        {
            try
            {
                var confirmOrderViewModel = new ConfirmOrderViewModel();
                if (productId.HasValue)
                {
                    confirmOrderViewModel.Product = ProductService.GetProductById(productId.Value);

                    confirmOrderViewModel.TopOrderInfos = OrderService.GetTopOrderList(1, 10);

                    var orderStatisModel = OrderService.GetOrderStatisModel(new List <int>()
                    {
                        10
                    });
                    var info = orderStatisModel.UserOrderList.FirstOrDefault(s => s.UserId == this.UserInfo.UserId);
                    if (info != null)
                    {
                        var walletViewModel = OrderService.GetWalletViewModel(this.UserInfo.UserId, new List <int>()
                        {
                            1, 2, 10
                        });
                        confirmOrderViewModel.Percentage = (((decimal)info.RowId / (decimal)orderStatisModel.TotalUserCount) * 100).ToString("F2");
                        confirmOrderViewModel.Earning    = walletViewModel.TotalIncome;
                    }
                    else
                    {
                        confirmOrderViewModel.Earning    = 0;
                        confirmOrderViewModel.Percentage = "0";
                    }
                }
                else
                {
                    return(RedirectToAction("Default", "Home"));
                }
                return(View(confirmOrderViewModel));
            }
            catch (Exception e)
            {
                logger.Error(e);
                throw;
            }
        }
        public ActionResult LockOrder(ConfirmOrderViewModel confirmModel)
        {
            string       userId      = User.Identity.GetUserId();
            ShoppingCart sessionCart = GetCartFromSession(userId);

            if (ModelState.IsValid)
            {
                sessionCart.Order.OrderStatus = "Locked";
                sessionCart.Save();
                AuditUser.LogAudit(28, string.Format("Order Number: {0}", sessionCart.Order.OrderNumber), User.Identity.GetUserId());

                string          reference = sessionCart.Order.OrderNumber.ToString();
                decimal         amount    = sessionCart.Order.TotalOrderValue * 100;
                ApplicationUser user      = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId());

                PaymentGatewayIntegration payObject = new PaymentGatewayIntegration(reference, amount, user.Email);

                payObject.Execute();

                if (!string.IsNullOrEmpty(payObject.Pay_Request_Id) && !string.IsNullOrEmpty(payObject.Checksum))
                {
                    ConfirmOrderViewModel model = new ConfirmOrderViewModel(sessionCart, payObject.Pay_Request_Id, payObject.Checksum);
                    model.TermsAndConditions = confirmModel.TermsAndConditions;

                    return(View("PayShoppingCart", model));
                }
                else
                {
                    ConfirmOrderViewModel model = new ConfirmOrderViewModel(sessionCart);

                    return(View("ConfirmShoppingCart", model));
                }
            }
            else
            {
                ConfirmOrderViewModel model = new ConfirmOrderViewModel(sessionCart);
                model.TermsAndConditions = confirmModel.TermsAndConditions;

                return(View("ConfirmShoppingCart", model));
            }
        }
Exemplo n.º 11
0
        public IActionResult Confirm()
        {
            if (!this.shoppingBagService.AnyProducts(this.User.Identity.Name))
            {
                this.TempData["error"] = ERROR_MESSAGE;
                return(RedirectToAction("Index", "Home"));
            }

            var order          = this.orderService.GetOrderByUsername(this.User.Identity.Name);
            var orderViewModel = new ConfirmOrderViewModel()
            {
                Id                          = order.Id,
                TotalPrice                  = order.TotalPrice,
                Recipient                   = order.Recipient,
                PhoneNumber                 = order.RecipientPhoneNumber,
                DeliveryAddressTown         = order.DeliveryAddress.Town,
                DeliveryAddressStreet       = order.DeliveryAddress.Street,
                DeliveryAddressCountry      = order.DeliveryAddress.Country,
                DeliveryAddressOtherDetails = order.DeliveryAddress.OtherDetails,
                DeliveryPrice               = DELIVERY_PRICE
            };

            return(this.View(orderViewModel));
        }
Exemplo n.º 12
0
 public ConfirmOrderCommand(ConfirmOrderViewModel model)
 {
     _id = model.Id;
 }
Exemplo n.º 13
0
        /// <summary>
        ///     Displays an order confirmation page which allows the user to place their order.
        /// </summary>
        /// <returns>
        ///     The order confirmation page if successful.
        ///     A redirection to another page if any information is invalid
        /// </returns>
        public async Task<ActionResult> ConfirmOrder()
        {
            Guid memberId = GetUserId();

            RedirectToRouteResult invalidStateResult = await EnsureCartNotEmptyAsync(memberId);
            if (invalidStateResult != null)
            {
                return invalidStateResult;
            }

            var orderCheckoutDetails = Session[OrderCheckoutDetailsKey] as WebOrderCheckoutDetails;

            invalidStateResult = EnsureValidSessionForConfirmStep(orderCheckoutDetails);
            if (invalidStateResult != null)
            {
                return invalidStateResult;
            }

            Contract.Assume(orderCheckoutDetails != null);

            /* Setup the address information */
            MemberAddress memberAddress = await GetShippingAddress(orderCheckoutDetails);
            if (memberAddress == null)
            {
                return RedirectToAction("ShippingInfo");
            }

            /* Setup the credit card information */
            string last4Digits = await GetLast4DigitsAsync(orderCheckoutDetails, memberId);
            if (last4Digits == null)
            {
                return RedirectToAction("BillingInfo");
            }

            var memberInfo =
                await db.Users.
                    Where(m => m.Id == memberId).
                    Select(u =>
                        new
                        {
                            FullName = u.FirstName + " " + u.LastName,
                            PhoneNumber = u.PhoneNumber
                        }
                    ).
                    SingleOrDefaultAsync();

            Cart cart = await GetCartWithLoadedProductsAsync(memberId);
            var cartItems = GetConfirmOrderCartItems(cart);

            /* Setup the view model with the gathered information */
            var webOrder = new ConfirmOrderViewModel
            {
                FullName = memberInfo.FullName,
                PhoneNumber = memberInfo.PhoneNumber,
                Address = memberAddress.Address,
                ProvinceName = memberAddress.Province.Name,
                CountryName = memberAddress.Country.CountryName,
                CreditCardLast4Digits = last4Digits.FormatLast4Digits(),
                Items = cartItems,
                ItemSubTotal = cartItems.Sum(ci => ci.ItemTotal)
            };

            webOrder.ShippingCost = shippingCostService.CalculateShippingCost(webOrder.ItemSubTotal, cart.Items);
            webOrder.TaxAmount = webOrder.ItemSubTotal * 
                (memberAddress.Province.ProvincialTaxRate + memberAddress.Country.FederalTaxRate);

            return View(webOrder);
        }
Exemplo n.º 14
0
 private void ConfirmationWindow_Loaded(object sender, RoutedEventArgs e)
 {
     ConfirmOrderVM = new ConfirmOrderViewModel();
     DataContext    = ConfirmOrderVM;
 }
Exemplo n.º 15
0
        public ActionResult ConfirmOrder(int id)
        {
            var model = new ConfirmOrderViewModel();
            model.ShoppingCart = this.shoppingCartService.GetShopingCart();
            model.DeliveryAddress = this.delliveryAddressesService
                .GetById(id)
                .To<DeliveryAddressViewModel>()
                .FirstOrDefault();

            if (!model.ShoppingCart.OrderedTickets.Any())
            {
                this.AddToastMessage(Messages.Sorry, Messages.NoItems, ToastType.Info);
                return this.RedirectToAction<HomeController>(c => c.Index());
            }

            return this.View(model);
        }
Exemplo n.º 16
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            ConfirmOrderViewModel ViewModel = new ConfirmOrderViewModel(e.Parameter as Order);

            DataContext = ViewModel;
        }
Exemplo n.º 17
0
        public JsonResult ConfirmOrder(ConfirmOrderViewModel model)
        {
            Response response;

            try
            {
                var userId = GetAuthenticatedUserId();
                OrderUsableProduct order = new OrderUsableProduct();
                using (var db = new KiaGalleryContext())
                {
                    var orderUsableProductDetail = db.OrderUsableProductDetail.Where(x => model.idList.Contains(x.Id)).ToList();
                    for (var i = 0; i < orderUsableProductDetail.Count; i++)
                    {
                        orderUsableProductDetail[i].Id = model.idList[i];
                        orderUsableProductDetail[i].PrintingHouseInventory = model.printingHouseInventory[i];
                        orderUsableProductDetail[i].ReadyForDelivery       = model.confirmDelivered[i];
                        orderUsableProductDetail[i].ConfirmDelivered       = model.confirmDelivered[i];
                        orderUsableProductDetail[i].RemainFinal            = model.remainFinal[i];
                        var query = orderUsableProductDetail.Where(x => x.OrderUsableProductId == model.orderId).ToList();
                        if (orderUsableProductDetail[i].ReadyForDelivery != null)
                        {
                            orderUsableProductDetail[i].ReadyForDelivery = model.confirmDelivered[i];
                        }

                        if (model.confirmDelivered[i] > model.readyForDelivery[i])
                        {
                            response = new Response()
                            {
                                status  = 500,
                                message = "کاربر محترم؛تعداد آماده تحویل بیشتر از تعداد قابل ساخت در چاپخانه می باشد."
                            };
                            return(Json(response, JsonRequestBehavior.AllowGet));
                        }
                    }
                    var sum = orderUsableProductDetail.Sum(x => x.RemainFinal);
                    if (sum == 0)
                    {
                        foreach (var item in orderUsableProductDetail)
                        {
                            item.OrderUsableProduct.PrintingHouserOrder      = true;
                            item.OrderUsableProduct.OrderUsableProductStatus = OrderUsableProductStatus.Sent;
                            item.OrderUsableProduct.PrintingHouseOrderStatus = PrintingHouseOrderStatus.Closed;
                            item.CreateUserId = userId;
                            item.ModifyUserId = userId;
                            item.CreateDate   = DateTime.Now;
                            item.ModifyDate   = DateTime.Now;
                            item.Ip           = Request.UserHostAddress;
                        }
                    }
                    else
                    {
                        foreach (var item in orderUsableProductDetail)
                        {
                            item.OrderUsableProduct.PrintingHouserOrder      = true;
                            item.OrderUsableProduct.OrderUsableProductStatus = OrderUsableProductStatus.InPreparation;
                            item.OrderUsableProduct.PrintingHouseOrderStatus = PrintingHouseOrderStatus.HalfOpen;
                            item.CreateUserId = userId;
                            item.ModifyUserId = userId;
                            item.CreateDate   = DateTime.Now;
                            item.ModifyDate   = DateTime.Now;
                            item.Ip           = Request.UserHostAddress;
                        }
                    }
                    var date = orderUsableProductDetail.Select(x => x.CreateDate).FirstOrDefault();
                    var orderCreateUserId = orderUsableProductDetail.Select(x => x.CreateUserId).FirstOrDefault();
                    var persianDate       = DateUtility.GetPersianDate(date);
                    var orderId           = orderUsableProductDetail.Select(x => x.OrderUsableProductId).FirstOrDefault();
                    var mobileNumber      = db.User.Where(x => x.Id == orderCreateUserId).FirstOrDefault().PhoneNumber;
                    var branchId          = orderUsableProductDetail.Select(x => x.OrderUsableProduct.Branch).FirstOrDefault();
                    var alias             = branchId.Alias;

                    //if (!User.IsInRole("admin"))
                    //{
                    //    Task.Factory.StartNew(() =>
                    //    {
                    //        NikSmsWebServiceClient.SendSmsNik("همکار گرامی؛" + "\n" + "سفارش شما به شماره سفارش" + "\n" + "SPLY-" + alias + "-" + orderId + "\n" + " درتاریخ " + persianDate + "تایید و در حال بررسی می باشد.", mobileNumber);
                    //    });
                    //}
                    //else
                    //{
                    //    Task.Factory.StartNew(() =>
                    //    {
                    //        NikSmsWebServiceClient.SendSmsNik("همکار گرامی؛" + "\n" + "سفارش شما به شماره سفارش" + "\n" + "SPLY-" + alias + "-" + orderId + "\n" + " درتاریخ " + persianDate + "تایید و در حال بررسی می باشد.", "09193121247");
                    //    });
                    //}
                    db.SaveChanges();
                }
                response = new Response()
                {
                    status  = 200,
                    message = "سفارش برای چاپخانه ارسال گردید."
                };
            }
            catch (Exception ex)
            {
                response = Core.GetExceptionResponse(ex);
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }