public ActionResult Order() { var viewModel = new OrderViewModel(); if (this.Request.Cookies[UserIdCart] != null) { var cart = this.shoppingService.GetByUserId(Request.Cookies[UserIdCart].Value); if (cart.ProductsCount > 0) { var productsIds = cart.ProductIds.Split(new string[] { "," } ,StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList(); var productsAsQuerable = this.ProductsService.GetByIds(productsIds).ToList(); var products = this.Mapper.Map<List<ProductViewModel>>(productsAsQuerable); var sizes = cart.Sizes.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList(); for (int i = 0; i < products.Count; i++) { products[i].Sizes.Clear(); } for (int i = 0; i < sizes.Count; i++) { var product = products.FirstOrDefault(p => p.Id == productsIds[i]); product.Sizes.Add(new SizeViewModel { Value = (short)sizes[i] }); } viewModel = new OrderViewModel { Products = products, TotalPrice = products.Sum(p => p.Price) }; } } return View(viewModel); }
public ActionResult Index() { var shipToId = SodaSession.ShipToId; var order = _productService.GetOrder(shipToId.Value, true); OrderViewModel vm = new OrderViewModel(); foreach (var item in order) { if (item.OrderQty != null) item.ExtAmt = item.Price * item.OrderQty.Value; item.SalesTaxAmt = item.TaxRate * item.Taxable * item.ExtAmt; if (item.OrderQty != null) item.CRVAmt = item.OrderQty.Value * item.CRVperUnit; vm.TaxTotal += item.SalesTaxAmt; vm.CSVTotal += item.CRVAmt; vm.GrandTotal += item.ExtAmt + item.SalesTaxAmt + item.CRVAmt; vm.SubTotal += item.ExtAmt; } var shippingInfo = _shippingService.GetShippingInfo(shipToId.Value); vm.Items = order; vm.ShippingInfo = shippingInfo; return View(vm); }
public void OnNavigatedTo(NavigationContext navigationContext) { if (navigationContext.Parameters != null && navigationContext.Parameters.Any()) { var dishes = navigationContext.Parameters["Dishes"] as List<DishViewModel>; if (dishes != null) ViewModel = new OrderViewModel(dishes) { Repository = Repository, NavigationService = navigationContext.NavigationService }; else ViewModel = new OrderViewModel { Repository = Repository, NavigationService = navigationContext.NavigationService }; } else ViewModel = new OrderViewModel { Repository = Repository, NavigationService = navigationContext.NavigationService }; }
public ActionResult Edit(OrderViewModel vmChanged, string redirectButton) { var vm = GetViewModelFromTempData<OrderViewModel>(); vm.ApplyFormAttributes(vmChanged.Model); return StoreEntity(vm, redirectButton); }
public ActionResult Create(OrderViewModel vmChanged, string redirectButton) { var vm = GetViewModelFromTempData<OrderViewModel>() ?? new OrderViewModel(new OrderDTO(), null, true); vm.DisplayName = Strings.OrderViewModel_DisplayName; vm.ApplyFormAttributes(vmChanged.Model); return StoreEntity(vm, redirectButton); }
// 构造函数 public MainPage() { InitializeComponent(); OrderViewModel = new OrderViewModel(); LayoutRoot.DataContext = OrderViewModel; // 用于本地化 ApplicationBar 的示例代码 //BuildLocalizedApplicationBar(); }
public OrderViewModel GetOrderDetailsx(int orderID) { OrderDataAccessService orderDataAccessService = new OrderDataAccessService(); OrderViewModel orderViewModel = new OrderViewModel(); List<OrderDetailProductResult> orderDetailProductResult = new List<OrderDetailProductResult>(); orderViewModel = orderDataAccessService.GetOrderDetails(orderID); OrderCustomer orderCustomer = orderDataAccessService.GetOrder(orderID); orderViewModel.OrderDetailProductResults = orderDetailProductResult; orderViewModel.Order = orderCustomer.Order; orderViewModel.Customer = orderCustomer.Customer; return orderViewModel; }
public virtual ActionResult Search() { var model = new SearchViewModel(ViewData.Model as BaseViewModel); var order = new OrderViewModel {Id = 100, Deadline = DateTime.Now, Title = "Karrbros Official", Group = "Best Group Evar"}; var order2 = new OrderViewModel {Id = 101, Deadline = DateTime.Now.AddDays(15), Title = "Clinton Wrestling", Group = "Time To Get Live" }; model.Orders.Add(order); model.Orders.Add(order2); var crumb = new BreadCrumbViewModel {Display = "Order Search", Title = "order search", Url = "/Order/Search"}; model.BreadCrumbs.Add(crumb); return View("Search", model); }
public void TestOrderViewModel() { OrderViewModel orderViewModel = new OrderViewModel(); orderViewModel.Service = serviceFacade; OrderListDTO order = new OrderListDTO() {Id = 1}; IList<OrderListDTO> orders = new List<OrderListDTO>() {order}; Expect.Once.On(serviceFacade).Method("GetAllOrders").Will(Return.Value(orders)); orderViewModel.LoadCommand.Command.Execute(null); Assert.AreEqual<int>(1, orderViewModel.Items.Count); Assert.AreEqual(order, orderViewModel.SelectedItem); Assert.AreEqual(Strings.OrderViewModel_DisplayName, orderViewModel.DisplayName); }
public ActionResult PlaceOrder(OrderViewModel vm) { var shipToId = SodaSession.ShipToId; if (vm.CreditCardExpDate != null) { var orderNumber = _productService.PlaceOrder(SodaSession.ShipToId.Value, vm.CreditCardNumber, vm.CreditCardExpDate.Value); if (orderNumber != null) { vm.OrderNumber = orderNumber.Value; return View(vm); } } return View(); }
public ActionResult GetOrder(int orderId) { var orderVm = new OrderViewModel() { //Address = "88 Coleman Parkway", ClientName = "Katherine Perkins", IsPaid = false, ItemName = "Exametazime", Quantity = 38, Subtotal = 297.72 }; return Json(orderVm, JsonRequestBehavior.AllowGet); }
public OrderViewModel BeginOrderEdit(int orderID) { OrderDataAccessService orderDataAccessService = new OrderDataAccessService(); OrderViewModel orderViewModel = new OrderViewModel(); OrderCustomer orderCustomer = orderDataAccessService.GetOrder(orderID); orderCustomer.Order.OrderTotal = orderDataAccessService.GetOrderTotal(orderID); orderCustomer.Order.OrderTotalFormatted = orderCustomer.Order.OrderTotal.ToString("C"); orderViewModel.Customer = orderCustomer.Customer; orderViewModel.Order = orderCustomer.Order; orderViewModel.Shippers = orderDataAccessService.GetShippers(); orderViewModel.Order.ShipperName = orderCustomer.Shipper.CompanyName; return orderViewModel; }
public OrderViewModel BeginOrderEntry(OrderViewModel orderViewModel) { // OrderViewModel orderViewModel = new OrderViewModel(); CustomerDataAccessService customerDataAccessService = new CustomerDataAccessService(); // Customer customer = customerDataAccessService.GetCustomerInformation(orderViewModel.Customer.CustomerID); orderViewModel.Customer = customerDataAccessService.GetCustomerInformation(orderViewModel.Customer.CustomerID); OrderDataAccessService orderDataAccessService = new OrderDataAccessService(); orderViewModel.Shippers = orderDataAccessService.GetShippers(); // OrderBusinessService orderBusinessService = new OrderBusinessService(); //orderViewModel.Order = orderBusinessService.InitializeOrderHeader(customer); return orderViewModel; }
public override ActionResult Index(RenderModel model) { int orderIndex = 1; if (CurrentPage.GetProperty("orderIndex") != null) Int32.TryParse(CurrentPage.GetProperty("orderIndex").Value.ToString(), out orderIndex); OrderOperationStatus operationStatus = _ecommerceService.GetOrder(orderIndex); if (operationStatus.Status) { var viewOrder = new OrderViewModel(model); viewOrder.InjectFrom(operationStatus.Order); viewOrder.Status = operationStatus.Status; viewOrder.Message = operationStatus.Message; return CurrentTemplate(viewOrder); } return ReturnErrorView(operationStatus, model); }
public async Task<IHttpActionResult> Get(long id) { var user = await _authRepository.FindUser(HttpContext.Current.User as ClaimsPrincipal); var entity = await _orderRepository.GetAsync(id); if (entity == null) { return NotFound(); } if (entity.UserId != user.Id) { return StatusCode(HttpStatusCode.Forbidden); } var viewModel = new OrderViewModel(); viewModel.Create(entity); return Ok(viewModel); }
public RmaRequestViewModel( IViewModelsFactory<ICreateRefundViewModel> wizardVmFactory, IViewModelsFactory<IOrderViewModel> orderVmFactory, IAuthenticationContext authContext, RmaRequest rmaRequestItem, OrderViewModel parentViewModel, OrderClient client) { _wizardVmFactory = wizardVmFactory; _orderVmFactory = orderVmFactory; CurrentRmaRequest = rmaRequestItem; _authContext = authContext; _parentViewModel = parentViewModel; _orderClient = client; RmaRequestWizardDialogInteractionRequest = new InteractionRequest<Confirmation>(); RmaRequestCancelCommand = new DelegateCommand(RaiseRmaRequestCancelInteractionRequest, () => CurrentRmaRequest.IsCancellable(client)); RmaRequestCompleteCommand = new DelegateCommand(RaiseRmaRequestCompleteInteractionRequest, () => CurrentRmaRequest.IsCompletable(client)); ExchangeOrderCreateCommand = new DelegateCommand(RaiseExchangeOrderCreateInteractionRequest, () => CurrentRmaRequest.IsAllowCreateExchangeOrder()); ExchangeOrderViewCommand = new DelegateCommand(RaiseExchangeOrderViewInteractionRequest, () => CurrentRmaRequest.ExchangeOrder != null); }
public ShipmentViewModel(OrderClient client, IViewModelsFactory<ISplitShipmentViewModel> splitVmFactory, IViewModelsFactory<ILineItemAddViewModel> wizardLineItemVmFactory, IViewModelsFactory<ILineItemViewModel> lineItemVmFactory, OrderViewModel orderViewModel, Shipment shipmentItem, IOrderEntityFactory entityFactory, IRepositoryFactory<IPricelistRepository> repositoryFactory, PriceListClient priceListClient) { _orderClient = client; ParentViewModel = orderViewModel; _currentOrder = orderViewModel._innerModel; CurrentShipment = shipmentItem; _entityFactory = entityFactory; _repositoryFactory = repositoryFactory; _priceListClient = priceListClient; _lineItemVmFactory = lineItemVmFactory; _wizardLineItemVmFactory = wizardLineItemVmFactory; _splitVmFactory = splitVmFactory; CommonShipmentConfirmRequest = orderViewModel.CommonOrderCommandConfirmRequest; ReleaseShipmentCommand = new DelegateCommand(RaiseReleaseShipmentInteractionRequest, () => CurrentShipment.IsReleaseable(_currentOrder.InnerItem, client)); CompleteShipmentCommand = new DelegateCommand(RaiseCompleteShipmentInteractionRequest, () => CurrentShipment.IsCompletable(_currentOrder.InnerItem, client)); CancelShipmentCommand = new DelegateCommand(RaiseCancelShipmentInteractionRequest, () => CurrentShipment.IsCancellable(_currentOrder.InnerItem, client)); AddLineItemCommand = new DelegateCommand(RaiseAddLineItemInteractionRequest, () => CurrentShipment.IsModifyable(_currentOrder.InnerItem)); MoveLineItemCommand = new DelegateCommand<ShipmentItem>(RaiseMoveLineItemInteractionRequest, x => x != null && CurrentShipment.IsModifyable(_currentOrder.InnerItem)); RemoveLineItemCommand = new DelegateCommand<ShipmentItem>(RaiseRemoveLineItemInteractionRequest, x => x != null && CurrentShipment.IsModifyable(_currentOrder.InnerItem)); ViewLineItemDetailsCommand = new DelegateCommand<object>(RaiseViewLineItemDetailsInteractionRequest, x => x != null); }
public ActionResult Order(int id) { var model = new OrderViewModel(); var userId = User.Identity.GetUserId(); var order = orderService.Find(id); if (order.UserId != userId) return RedirectToAction("Index"); Mapper.Map(order, model); foreach (var item in model.Items) { string optionsDisplay = ""; var options = JsonConvert.DeserializeObject<OrderItemOption[]>(item.Options); foreach (var optionId in options.Select(o => o.Id)) { var option = optionService.Find(optionId); if (option == null) continue; optionsDisplay += string.Format("<strong>{0}</strong>: {1} ", option.Category.Name, option.Name); } item.OptionsDisplay = optionsDisplay; } return View(model); }
public FormViewModel(BaseViewModel model) { Cart = model.Cart; Order = new OrderViewModel(); }
public OrderViewModel CreateOrder(OrderViewModel orderViewModel) { CartDataAccessService cartDataAccessService = new CartDataAccessService(); return cartDataAccessService.CreateOrder(orderViewModel); }
private void RefreshOrderDetailViewModel(OrderViewModel vm, OrderDTO item) { var vmOrderDetail = GetViewModelFromTempData<OrderDetailViewModel>(typeof(OrderDetailController).FullName); if (vmOrderDetail != null && vmOrderDetail.LatestControllerAction != ControllerAction.None) { vm.OrderDetails = vmOrderDetail; } else { vm.OrderDetails = new OrderDetailViewModel(item.Details.ToList()); } vm.OrderDetails.IsReadOnly = CurrentActionName == "Details"; vm.OrderDetails.ReturnController = CurrentControllerName; vm.OrderDetails.ReturnAction = CurrentActionName; vm.OrderDetails.ReturnId = CurrentParameterId; }
public async Task<IHttpActionResult> Delete(long id, string username) { var user = await _authRepository.FindUser(username); var isAdmin = await _authRepository.IsAdmin(HttpContext.Current.User as ClaimsPrincipal); var entity = await _orderRepository.FindAsync(o => o.ProductId == id && o.UserId == user.Id); if (entity == null) { return NotFound(); } var order = entity.FirstOrDefault(); if(order == null) { return NotFound(); } if (!isAdmin) { return StatusCode(HttpStatusCode.Forbidden); } _orderRepository.Remove(order); await _unitOfWork.CompleteAsync(); var viewModel = new OrderViewModel(); viewModel.Create(order); return Ok(viewModel); }
public ActionResult Order(OrderViewModel model) { for (int i = 0; i < model.Products.Count; i++) { this.shoppingService.OrderProductBySize(model.Products[i].Id, model.Products[i].Sizes.FirstOrDefault().Value); } this.HttpContext.Response.Cache.SetNoStore(); var userId = this.HttpContext.User.Identity.GetUserId(); this.shoppingService.AddOrder(model.TotalPrice, userId, this.Mapper.Map<List<Product>>(model.Products), Request.Cookies[UserIdCart].Value); return Redirect("/orders/index"); }
private void MarkOrderDetailChanges(OrderViewModel vm) { switch (vm.OrderDetails.LatestControllerAction) { case ControllerAction.Create: foreach (var ins in vm.OrderDetails.Items.Where(i => i.Id <= 0)) vm.Model.MarkChildForInsertion(ins); break; case ControllerAction.Edit: if (!string.IsNullOrEmpty(ReferrerParameterId)) vm.Model.MarkChildForUpdate(vm.OrderDetails.SelectedItem); break; case ControllerAction.Delete: foreach (var del in vm.OrderDetails.ItemsToDelete) vm.Model.MarkChildForDeletion(del); break; } }
protected ActionResult StoreEntity(OrderViewModel vm, string redirectButton) { bool persist = string.IsNullOrEmpty(redirectButton); try { if (ModelState.IsValid && persist) { Service.StoreOrder(vm.Model); // Finish Action and go back to Index RemoveViewModelFromTempData<OrderViewModel>(); RemoveViewModelFromTempData<OrderDetailViewModel>(typeof(OrderDetailController).FullName); return RedirectToAction("Index"); } } catch (Exception ex) { ModelState.AddModelError("Error", ex); } // Finish Action without saving StoreViewModelToTempData(vm); StoreViewModelToTempData(vm.OrderDetails, typeof(OrderDetailController).FullName); if (persist) return View(vm); else return Redirect(redirectButton); }
public ActionResult CheckoutReview() { int CustomerID = 0; string ErrorMessage = ""; string retMsg = ""; string token = ""; string PayerID = "5678912340"; NVPCodec decoder = new NVPCodec(); token = Session["token"].ToString(); OrderViewModel orderViewModel = new OrderViewModel(); NVPAPICaller payPalCaller = new NVPAPICaller(); CustomerDataAccessService customerDataAccessService = new CustomerDataAccessService(); var Cart = ShoppingCartActions.GetCart(); string CartID = Cart.ShoppingCartId; orderViewModel.Order.CartID = CartID; bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg); if (ret) { Session["payerId"] = PayerID; CustomerID = customerDataAccessService.GetCustomerIdNumber(User.Identity.Name); orderViewModel.Order.CustomerID = CustomerID; orderViewModel.Order.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString()); orderViewModel.Order.UserName = User.Identity.Name; orderViewModel.Order.FirstName = decoder["FIRSTNAME"].ToString(); orderViewModel.Order.LastName = decoder["LASTNAME"].ToString(); orderViewModel.Order.SheepToStreet = decoder["SHIPTOSTREET"].ToString(); orderViewModel.Order.ShipCity = decoder["SHIPTOCITY"].ToString(); orderViewModel.Order.ShipToState = decoder["SHIPTOSTATE"].ToString(); orderViewModel.Order.ShipPostalCode = decoder["SHIPTOZIP"].ToString(); orderViewModel.Order.ShipCountry = decoder["SHIPTOCOUNTRYCODE"].ToString(); orderViewModel.Order.Email = decoder["EMAIL"].ToString(); orderViewModel.Order.OrderTotal = Convert.ToDouble(decoder["AMT"].ToString()); orderViewModel.Customer.CustomerID = CustomerID; // Verify total payment amount as set on CheckoutStart.aspx. try { decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString()); decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString()); if (paymentAmountOnCheckout != paymentAmoutFromPayPal) { ErrorMessage = "Amount%20total%20mismatch."; return RedirectToAction("CheckoutError", ErrorMessage); } } catch (Exception) { ErrorMessage = "Amount%20total%20mismatch."; return RedirectToAction("CheckoutError", ErrorMessage); } //Process the order OrderApplicationService orderApplicationService = new OrderApplicationService(); orderViewModel = orderApplicationService.CreateOrder(orderViewModel); orderViewModel = orderApplicationService.BeginOrderEntry(orderViewModel); Session["currentOrderId"] = orderViewModel.Order.OrderID; } else { RedirectToAction("CheckoutError", retMsg); } return View("CheckoutReview", orderViewModel); }
public OrderViewModel LoadOrderDetailProduct(List<HiLToysDataModel.OrderDetailProductResult> OrderDetailProductResult) { OrderViewModel orderViewModel = new OrderViewModel(); orderViewModel.Order.OrderID = OrderDetailProductResult[0].OrderID; orderViewModel.Order.OrderDate = OrderDetailProductResult[0].OrderDate; OrderCustomer orderCustomer = new OrderCustomer(); orderCustomer.Customer.CustomerID = OrderDetailProductResult[0].CustomerID; orderCustomer.Customer.FirstName = OrderDetailProductResult[0].FirstName; orderCustomer.Customer.LastName = OrderDetailProductResult[0].LastName; orderViewModel.Customer = orderCustomer.Customer; for (int i = 0; i < OrderDetailProductResult.Count; i++) { orderViewModel.OrderDetailProducts[i].Products.ProductID = OrderDetailProductResult[i].ProductID; orderViewModel.OrderDetailProducts[i].Products.ProductName = OrderDetailProductResult[i].ProductName; orderViewModel.OrderDetailProducts[i].Products.QuantityPerUnit = OrderDetailProductResult[i].QuantityPerUnit; orderViewModel.OrderDetailProducts[i].Products.UnitPrice = OrderDetailProductResult[i].UnitPrice; orderViewModel.OrderDetailProducts[i].OrderDetail.Quantity = OrderDetailProductResult[i].Quantity; orderViewModel.OrderDetailProducts[i].OrderDetail.OrderDate = OrderDetailProductResult[i].OrderDate; orderViewModel.OrderDetailProducts[i].OrderDetail.Discount = OrderDetailProductResult[i].Discount; } return orderViewModel; }
public void OnNavigatedFrom(NavigationContext navigationContext) { ViewModel = null; }
public void SetOrderWindowReference(OrderViewModel orderViewModel) { _orderViewModel = orderViewModel; }
private bool NeedsRefresh(OrderViewModel vm, int id) { // True when Id changed if (vm?.Model?.Id != id) return true; // True when coming from other Controller if (ReferrerControllerName == "Order" && ReferrerActionName != "Index") return false; if (ReferrerControllerName == "OrderDetail") return false; return true; }