public ActionResult Detail(long id, string mode) { var model = new DetailViewModel(); var detailModel = new List <PaymentDetailViewModel>(); Payment payment = paymentProvider.GetPayment(id); var paymentDetail = paymentProvider.GetPaymentDetail(id); var orderDetail = orderProvider.GetOrderDetail(payment.OrderId); var order = orderProvider.GetOrder(payment.OrderId); mapper.Map(payment, model); mapper.Map(paymentDetail, detailModel); //model.ServiceCharge = order.ServiceCharge; model.TaxValue = order.TaxAmount; model.DeliveryCharge = order.DeliveryCharge; model.DiscValue = order.DiscValue; model.OrderId = order.Id; model.UnitPriceMode = orderProvider.GetUnitPriceMode(order.UnitPriceMode); model.List = detailModel; model.OrderDetails = mapper.Map <List <OrderViewModel.OrderDetailEntryViewModel> >(orderDetail); ViewBag.mode = mode.XorString(); if (!IsDetailModeValid(ViewBag.mode)) { return(RedirectToAction("Index", "Home", new { area = String.Empty })); } return(View(model)); }
public ActionResult Print() { string orderNum = WebUtil.GetQueryStringValue <string>("orderNum", string.Empty); Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder(); OutStorageEntity entity = new OutStorageEntity(); entity.OrderNum = orderNum; entity = bill.GetOrder(entity); entity = entity.IsNull() ? new OutStorageEntity() : entity; ViewBag.Entity = entity; OutStoDetailEntity detail = new OutStoDetailEntity(); detail.OrderNum = orderNum; List <OutStoDetailEntity> listResult = bill.GetOrderDetail(detail); listResult = listResult.IsNull() ? new List <OutStoDetailEntity>() : listResult; OrderProvider orderProvider = new OrderProvider(); foreach (OutStoDetailEntity item in listResult) { OrderDetailEntity orderDetail = new OrderDetailEntity(); orderDetail.Where(a => a.SnNum == item.ContractSn).And(a => a.OrderNum == item.ContractOrder); orderDetail = orderProvider.GetOrderDetail(orderDetail); if (orderDetail != null) { item.Qty = orderDetail.Num; } } ViewBag.Detail = listResult; return(View()); }
public ActionResult Edit(long id) { var orderViewModel = new CreateEditViewModel(); var orderDetailViewModel = new List <OrderDetailEntryViewModel>(); var order = orderProvider.GetOrder(id); if (order != null) { var orderDetail = orderProvider.GetOrderDetail(order.Id); if (orderDetail != null) { mapper.Map(order, orderViewModel); mapper.Map(orderDetail, orderDetailViewModel); OrderDetailSessionWrapper.Initialize(orderDetailViewModel); return(View("CreateEdit", orderViewModel)); } } return(View("Index")); }
/// <summary> /// Builds the basket. /// </summary> /// <param name="connector">The connector.</param> /// <param name="order">The order.</param> /// <returns> /// A string containing the contents of the order /// </returns> private static string BuildBasket(CrmConnector connector, OrderProvider orderProvider, SalesOrder order) { StringBuilder basket = new StringBuilder(); // A basket item comprises of Product Name, Quantity, Unit Cost, Tax, Cost inc. Tax, and Total Cost (Cost*Quantity). These are all seperated with colons (i.e. %3A). string basketItem = String.Empty; string seperator = "%3A"; // Get a list of the names for the level Option Set. MetaDataProvider metaDataProvider = new MetaDataProvider(connector); OptionMetadataCollection levelOptionSetLabels = metaDataProvider.RetrieveOptionSetMetaDataCollection(SalesOrderDetail.EntityLogicalName, "lss_level"); int basketCount = 0; List <SalesOrderDetail> productExtras; List <SalesOrderDetail> orderDetails = orderProvider.GetOrderDetail(order.Id, ProductType.Course); foreach (SalesOrderDetail detail in orderDetails) { string basketItemName = GetBasketNameOfProduct(detail, levelOptionSetLabels); // Add name of basket item with a hard-coded Quantity of 1 basketItem = seperator + basketItemName + seperator + "1" + seperator; // For each product check if it has any related products productExtras = orderProvider.GetProductExtras(detail.Id); decimal extraUnitCost = 0; decimal extraTax = 0; decimal extraTotal = 0; foreach (SalesOrderDetail extra in productExtras) { extraUnitCost += extra.BaseAmount == null ? 0 : extra.BaseAmount.Value; extraTax += extra.Tax == null ? 0 : extra.Tax.Value; extraTotal += extra.ExtendedAmount == null ? 0 : extra.ExtendedAmount.Value; } // Add unit cost basketItem += (detail.BaseAmount.Value + extraUnitCost).ToString("#.##") + seperator; // Add Tax basketItem += detail.Tax == null ? "0" : (detail.Tax.Value + extraTax).ToString("#.##") + seperator; // Add Cost inc. Tax basketItem += (detail.ExtendedAmount.Value + extraTotal).ToString("#.##") + seperator; // Add Total Cost basketItem += (detail.ExtendedAmount.Value + extraTotal).ToString("#.##"); basket.Append(basketItem); basketCount++; } basket.Insert(0, "&Basket=" + basketCount.ToString()); return(basket.ToString()); }