public virtual IActionResult PrintOrderDetails(int orderId) { var order = _orderService.GetOrderById(orderId); if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return(Challenge()); } var model = _orderModelFactory.PrepareOrderDetailsModel(order); model.PrintMode = true; return(View("Details", model)); }
private void PrepareRecurringPaymentHistoryModel(RecurringPaymentModel.RecurringPaymentHistoryModel model, RecurringPaymentHistory history) { Guard.NotNull(model, nameof(model)); Guard.NotNull(history, nameof(history)); var order = _orderService.GetOrderById(history.OrderId); model.Id = history.Id; model.OrderId = history.OrderId; model.RecurringPaymentId = history.RecurringPaymentId; model.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); model.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); model.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); model.CreatedOn = _dateTimeHelper.ConvertToUserTime(history.CreatedOnUtc, DateTimeKind.Utc); }
public ActionResult ListReviewsAdmin(int VendorId, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageVendors)) { return(Content("Access denied")); } var records = _extendedVendorService.GetVendorReviews(VendorId, null, null, command.Page, command.PageSize); var dataModel = records.Select(x => { var order = _orderService.GetOrderById(x.OrderId); var orderItems = order.OrderItems.First(oi => oi.Product.Id == x.ProductId); return(x.ToModel(order, orderItems.Product)); }); var model = new DataSourceResult { Data = dataModel, Total = records.Count }; return(new JsonResult { Data = model }); }
public ActionResult ResultHandler() { var parameters = GetParameters(Request.Params); int orderId; if (!int.TryParse(parameters["trnOrderNumber"], out orderId)) { return(RedirectToRoute("HomePage")); } var order = _orderService.GetOrderById(orderId); if (order == null) { return(RedirectToRoute("HomePage")); } var sb = new StringBuilder(); sb.AppendLine("Beanstream payment result:"); foreach (var parameter in parameters) { sb.AppendFormat("{0}: {1}{2}", parameter.Key, parameter.Value, Environment.NewLine); } //order note order.OrderNotes.Add(new OrderNote() { Note = sb.ToString(), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(order); return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id })); }
public async Task <ActionResult <IReadOnlyList <OrderToReturnDto> > > GetOrdersById(int Id) { var email = HttpContext.User.RetrieveEmailFromPrincipal(); var order = await _orderService.GetOrderById(Id, email); if (order == null) { return(NotFound(new ApiResponse(404))); } var result = _mapper.Map <Order, OrderToReturnDto>(order); return(Ok(result)); }
public ActionResult MerchantReturn(FormCollection form) { var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.eWayHosted") as eWayHostedPaymentProcessor; if (processor == null || !processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed) { throw new NopException("eWayHosted module cannot be loaded"); } var accessPaymentCode = string.Empty; if (form["AccessPaymentCode"] != null) { accessPaymentCode = Request.Form["AccessPaymentCode"]; } //get the result of the transaction based on the unique payment code var validationResult = processor.CheckAccessCode(accessPaymentCode); if (!string.IsNullOrEmpty(validationResult.ErrorMessage)) { //failed return(RedirectToAction("Index", "Home", new { area = "" })); } if (string.IsNullOrEmpty(validationResult.TrxnStatus) || !validationResult.TrxnStatus.ToLower().Equals("true")) { //failed return(RedirectToAction("Index", "Home", new { area = "" })); } var orderId = Convert.ToInt32(validationResult.MerchnatOption1); var order = _orderService.GetOrderById(orderId); if (order == null) { return(RedirectToAction("Index", "Home", new { area = "" })); } if (_orderProcessingService.CanMarkOrderAsPaid(order)) { _orderProcessingService.MarkOrderAsPaid(order); } return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id })); }
public virtual async Task <IActionResult> GetOrderNoteFile(string orderNoteId) { var orderNote = await _orderService.GetOrderNote(orderNoteId); if (orderNote == null) { return(InvokeHttp404()); } var order = await _orderService.GetOrderById(orderNote.OrderId); if (order == null) { return(InvokeHttp404()); } if (_workContext.CurrentCustomer == null || order.CustomerId != _workContext.CurrentCustomer.Id) { return(Challenge()); } var download = await _downloadService.GetDownloadById(orderNote.DownloadId); if (download == null) { return(Content("Download is not available any more.")); } if (download.UseDownloadUrl) { return(new RedirectResult(download.DownloadUrl)); } //binary download if (download.DownloadBinary == null) { return(Content("Download data is not available any more.")); } //return result string fileName = !String.IsNullOrWhiteSpace(download.Filename) ? download.Filename : orderNote.Id.ToString(); string contentType = !String.IsNullOrWhiteSpace(download.ContentType) ? download.ContentType : "application/octet-stream"; return(new FileContentResult(download.DownloadBinary, contentType) { FileDownloadName = fileName + download.Extension }); }
/// <summary> /// Prepare paged discount usage history list model /// </summary> /// <param name="searchModel">Discount usage history search model</param> /// <param name="discount">Discount</param> /// <returns>Discount usage history list model</returns> public virtual DiscountUsageHistoryListModel PrepareDiscountUsageHistoryListModel(DiscountUsageHistorySearchModel searchModel, Discount discount) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (discount == null) { throw new ArgumentNullException(nameof(discount)); } //get discount usage history var history = _discountService.GetAllDiscountUsageHistory(discountId: discount.Id, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new DiscountUsageHistoryListModel { Data = history.Select(historyEntry => { //fill in model values from the entity var discountUsageHistoryModel = new DiscountUsageHistoryModel { Id = historyEntry.Id, DiscountId = historyEntry.DiscountId, OrderId = historyEntry.OrderId }; //convert dates to the user time discountUsageHistoryModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(historyEntry.CreatedOnUtc, DateTimeKind.Utc); //fill in additional values (not existing in the entity) var order = _orderService.GetOrderById(historyEntry.OrderId); if (order != null) { discountUsageHistoryModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); discountUsageHistoryModel.CustomOrderNumber = order.CustomOrderNumber; } return(discountUsageHistoryModel); }), Total = history.TotalCount }; return(model); }
public LiquidShipmentItem(ShipmentItem shipmentItem, Shipment shipment, string languageId) { this._productService = EngineContext.Current.Resolve <IProductService>(); this._orderService = EngineContext.Current.Resolve <IOrderService>(); this._productAttributeParser = EngineContext.Current.Resolve <IProductAttributeParser>(); this._catalogSettings = EngineContext.Current.Resolve <CatalogSettings>(); this._shipmentItem = shipmentItem; this._languageId = languageId; this._shipment = shipment; this._order = _orderService.GetOrderById(_shipment.OrderId); this._orderItem = _order.OrderItems.Where(x => x.Id == _shipmentItem.OrderItemId).FirstOrDefault(); this._product = _productService.GetProductById(_orderItem.ProductId); AdditionalTokens = new Dictionary <string, string>(); }
/// <summary> /// Prepare paged recurring payment history list model /// </summary> /// <param name="searchModel">Recurring payment history search model</param> /// <param name="recurringPayment">Recurring payment</param> /// <returns>Recurring payment history list model</returns> public virtual RecurringPaymentHistoryListModel PrepareRecurringPaymentHistoryListModel(RecurringPaymentHistorySearchModel searchModel, RecurringPayment recurringPayment) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } if (recurringPayment == null) { throw new ArgumentNullException(nameof(recurringPayment)); } //get recurring payments history var recurringPayments = recurringPayment.RecurringPaymentHistory .OrderBy(historyEntry => historyEntry.CreatedOnUtc).ToList() .ToPagedList(searchModel); //prepare list model var model = new RecurringPaymentHistoryListModel().PrepareToGrid(searchModel, recurringPayments, () => { return(recurringPayments.Select(historyEntry => { //fill in model values from the entity var historyModel = historyEntry.ToModel <RecurringPaymentHistoryModel>(); //convert dates to the user time historyModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(historyEntry.CreatedOnUtc, DateTimeKind.Utc); //fill in additional values (not existing in the entity) var order = _orderService.GetOrderById(historyEntry.OrderId); if (order == null) { return historyModel; } historyModel.OrderStatus = _localizationService.GetLocalizedEnum(order.OrderStatus); historyModel.PaymentStatus = _localizationService.GetLocalizedEnum(order.PaymentStatus); historyModel.ShippingStatus = _localizationService.GetLocalizedEnum(order.ShippingStatus); historyModel.CustomOrderNumber = order.CustomOrderNumber; return historyModel; })); }); return(model); }
public ActionResult Completed(int?orderId) { ////validation //if ((_workContext.CurrentCustomer.IsGuest() && !_orderSettings.AnonymousCheckoutAllowed)) // return new HttpUnauthorizedResult(); GutterCleanOrder order = null; if (orderId.HasValue) { //load order by identifier (if provided) order = _orderService.GetOrderById(orderId.Value); } if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return(RedirectToRoute("HomePage")); } //model var model = new CheckoutCompletedModel { OrderId = order.Id, }; model.QuestionDeliveryTimeStr = "5 business days"; if (order.QuestionDeliveryTime == 1) { model.QuestionDeliveryTimeStr = "5 business days"; } if (order.QuestionDeliveryTime == 2) { model.QuestionDeliveryTimeStr = "8 hours"; } if (order.QuestionDeliveryTime == 3) { model.QuestionDeliveryTimeStr = "4 hours"; } return(View(model)); }
public IActionResult SuccessCallbackHandler(IpnModel model) { var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.Moneris") as MonerisPaymentProcessor; if (processor == null || !processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed) { throw new NopException("Moneris module cannot be loaded"); } var parameters = model.Form; if (string.IsNullOrEmpty(GetValue("transactionKey", parameters)) || string.IsNullOrEmpty(GetValue("rvar_order_id", parameters))) { return(RedirectToAction("Index", "Home", new { area = "" })); } var transactionKey = GetValue("transactionKey", parameters); if (!processor.TransactionVerification(transactionKey, out Dictionary <string, string> values)) { return(RedirectToAction("Index", "Home", new { area = "" })); } var orderIdValue = GetValue("rvar_order_id", parameters); if (!int.TryParse(orderIdValue, out int orderId)) { return(RedirectToAction("Index", "Home", new { area = "" })); } var order = _orderService.GetOrderById(orderId); if (order == null || !_orderProcessingService.CanMarkOrderAsPaid(order)) { return(RedirectToAction("Index", "Home", new { area = "" })); } if (values.ContainsKey("txn_num")) { order.AuthorizationTransactionId = values["txn_num"]; _orderService.UpdateOrder(order); } _orderProcessingService.MarkOrderAsPaid(order); return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id })); }
public ServiceDataWrapper <OrderRequest> Get([FromRoute] int id) { var orderFilter = new OrderFilter(); if (HttpContext.GetRole().Equals(ApplicationConstant.ApplicationRoles.Customer)) { orderFilter.CustomerId = HttpContext.GetUserId(); } else { orderFilter.RetailerId = HttpContext.GetUserId(); } return(new ServiceDataWrapper <OrderRequest> { value = _service.GetOrderById(id, orderFilter).Result }); }
public (IEnumerable <GiftCardModel.GiftCardUsageHistoryModel> giftCardUsageHistoryModels, int totalCount) PrepareGiftCardUsageHistoryModels(GiftCard giftCard, int pageIndex, int pageSize) { var usageHistoryModel = giftCard.GiftCardUsageHistory.OrderByDescending(gcuh => gcuh.CreatedOnUtc) .Select(x => new GiftCardModel.GiftCardUsageHistoryModel { Id = x.Id, OrderId = x.UsedWithOrderId, OrderNumber = _orderService.GetOrderById(x.UsedWithOrderId) != null ? _orderService.GetOrderById(x.UsedWithOrderId).OrderNumber : 0, UsedValue = _priceFormatter.FormatPrice(x.UsedValue, true, false), CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc) }) .ToList(); return( usageHistoryModel.Skip((pageIndex - 1) * pageSize).Take(pageSize), usageHistoryModel.Count); }
public IActionResult Details(int?id) { if (id == null) { return(View("BadRequest")); } try { OrderDetailsViewModel orderDetailsViewModel = _orderService.GetOrderById(id.Value); return(View(orderDetailsViewModel)); } catch (Exception ex) { return(View("ExceptionView")); } }
public async Task Handle(EntityDeleted <MerchandiseReturn> notification, CancellationToken cancellationToken) { var order = await _orderService.GetOrderById(notification.Entity.OrderId); if (order != null) { foreach (var item in notification.Entity.MerchandiseReturnItems) { var orderItem = order.OrderItems.FirstOrDefault(x => x.Id == item.OrderItemId); if (orderItem != null) { orderItem.ReturnQty -= item.Quantity; } } await _orderService.UpdateOrder(order); } }
public IActionResult GetAllProductsInOrder(int orderId) { try { var order = _orderService.GetOrderById(orderId); var orderedProducts = _orderService.GetAllProductsInOrder(order); var productDTOs = _mapper.Map <List <OLIDTO> >(orderedProducts); return(Ok(productDTOs)); } catch (Exception) { // TODO: Check if this is the right error code for this. return(StatusCode(500)); } }
public ActionResult OrderInfo(int orderId) { var order = _orderService.GetOrderById(orderId); //ViewBag.Status = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return(new HttpUnauthorizedResult()); } var model = PrepareOrderDetailsModel(order); return(PartialView(model)); }
public async Task <IActionResult> Update([FromBody] UpdateOrderRequest updateOrder) { try { var updated = await _orderService.UpdateOrderAsync(updateOrder.orderId, updateOrder.status, updateOrder.rejectReason); if (updated == 1) { var order = _orderService.GetOrderById(updateOrder.orderId); if (updateOrder.status == 5 && !string.IsNullOrEmpty(Convert.ToString(order.CouponId)) && order.CouponId != 0) { PromoCodeQuantityPlusOne(Convert.ToInt32(order.CouponId)); var orderItem = await _orderItemService.GetOrderItems(updateOrder.orderId); if (orderItem.Count > 0) { for (int i = 0; i < orderItem.Count; i++) { ProductQuantityPlus(orderItem[i].ProductId, orderItem[i].Quantity); } } } return(Ok(new { status = Ok().StatusCode, message = "order update Successfully" })); } return(NotFound(new { status = NotFound().StatusCode, message = "Internal Server error" })); } catch (Exception ex) { return(BadRequest(new { status = BadRequest().StatusCode, message = ex.Message })); } }
/// <summary> /// Executes a task /// </summary> public void Execute() { var list = _orderService.GetOrdersNotContainsAxId(); if (list.Any()) { foreach (var order in list) { var result = System.Threading.Tasks.Task.Run(async() => await SendOrder(order)).Result; var currentOrder = _orderService.GetOrderById(order.Id); if (!string.IsNullOrEmpty(result)) { currentOrder.AXLink = result; _orderService.UpdateOrder(currentOrder); } } } }
//GET: ContactAdmin/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var orderModel = await _orderService.GetOrderById(id); if (orderModel == null) { return(NotFound()); } var orderProductList = await _productService.GetProductsByIdList(orderModel.Cart.ItemList.Select(e => e.ProductId).ToList()); ViewData["orderModel"] = orderModel; return(View(orderProductList)); }
public ActionResult OrderDetail(int orderId) { if (!_workContext.CurrentCustomer.IsRegistered()) { return(new HttpUnauthorizedResult()); } var order = _orderService.GetOrderById(orderId); if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return(new HttpUnauthorizedResult()); } var model = PrepareOrderDetailsModel(order); return(View(model)); }
public IHttpActionResult Details([FromBody] OrderOperateModel ordermodel) { if (!_customerService.CheckLogin(ordermodel.login.userid, ordermodel.login.logguid)) { return(Ok(new { success = false, msg = "登录超时" })); } var order = _orderService.GetOrderById(ordermodel.orderId); var currentCustomer = _customerService.GetCustomerById(ordermodel.login.userid); if (order == null || order.Deleted || currentCustomer.Id != order.CustomerId) { return(Ok()); } var model = PrepareOrderDetailsModel(order); return(Ok(model)); }
public ActionResult <OrderDto> Get(long id) { try { var order = _service.GetOrderById(id); if (order == null) { return(NotFound()); } var result = _mapper.Map <Order, OrderDto>(order); return(Ok(result)); } catch (ArgumentOutOfRangeException) { return(BadRequest()); } }
public IActionResult Create(string address, int paymentType, int orderId) { if (ModelState.IsValid) { UserViewModel user = _userService.GetCurrentUser(User.Identity.Name); InvoiceVM model = new InvoiceVM(); model.Address = address; model.PaymentType = (PaymentTypeVM)paymentType; OrderVM order = _orderService.GetOrderById(orderId); if (order != null) { model.OrderVM = order; _invoiceService.Insert(model, user.Id, orderId); } } return(RedirectToAction("invoice", new { orderId })); }
/// <summary> /// Prepare paged recurring payment list model /// </summary> /// <param name="searchModel">Recurring payment search model</param> /// <returns>Recurring payment list model</returns> public virtual RecurringPaymentListModel PrepareRecurringPaymentListModel(RecurringPaymentSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get recurringPayments var recurringPayments = _orderService.SearchRecurringPayments(showHidden: true, pageIndex: searchModel.Page - 1, pageSize: searchModel.PageSize); //prepare list model var model = new RecurringPaymentListModel().PrepareToGrid(searchModel, recurringPayments, () => { return(recurringPayments.Select(recurringPayment => { //fill in model values from the entity var recurringPaymentModel = recurringPayment.ToModel <RecurringPaymentModel>(); var order = _orderService.GetOrderById(recurringPayment.InitialOrderId); var customer = _customerService.GetCustomerById(order.CustomerId); //convert dates to the user time if (_orderProcessingService.GetNextPaymentDate(recurringPayment) is DateTime nextPaymentDate) { recurringPaymentModel.NextPaymentDate = _dateTimeHelper .ConvertToUserTime(nextPaymentDate, DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture); recurringPaymentModel.CyclesRemaining = _orderProcessingService.GetCyclesRemaining(recurringPayment); } recurringPaymentModel.StartDate = _dateTimeHelper .ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(CultureInfo.InvariantCulture); //fill in additional values (not existing in the entity) recurringPaymentModel.CustomerId = customer.Id; recurringPaymentModel.InitialOrderId = order.Id; recurringPaymentModel.CyclePeriodStr = _localizationService.GetLocalizedEnum(recurringPayment.CyclePeriod); recurringPaymentModel.CustomerEmail = _customerService.IsRegistered(customer) ? customer.Email : _localizationService.GetResource("Admin.Customers.Guest"); return recurringPaymentModel; })); });
/// <summary> /// Post process payment (used by payment gateways that require redirecting to a third-party URL) /// </summary> /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param> public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest) { //create common query parameters for the request var queryParameters = CreateQueryParameters(postProcessPaymentRequest); string jsonString = JsonConvert.SerializeObject(queryParameters); var url = GetPointCheckoutBaseUrl() + "/api/v1.0/checkout"; HttpClient pointCheckoutClient = getPointcheckoutHttpClient(url); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url) { Content = new StringContent(jsonString, Encoding.UTF8, "application/json") }; try { pointCheckoutClient.CancelPendingRequests(); HttpResponseMessage response = pointCheckoutClient.SendAsync(request).Result; string responseString = response.Content.ReadAsStringAsync().Result; PointCheckoutResponse responseObject = JsonConvert.DeserializeObject <PointCheckoutResponse>(responseString); if (responseObject.success) { string redirectUrl = GetPointCheckoutBaseUrl() + "/checkout/" + responseObject.result.checkoutKey; var order = _orderService.GetOrderById(int.Parse(responseObject.result.referenceId)); //add a note order.OrderNotes.Add(new OrderNote() { Note = getOrderHistoryCommentMessage(responseObject.result.checkoutId, responseObject.result.status, responseObject.result.currency, 0), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(order); _httpContextAccessor.HttpContext.Response.Redirect(redirectUrl); return; } else { throw new NopException("ERROR: " + responseObject.error); } }catch (Exception ex) { ex.GetBaseException(); _httpContextAccessor.HttpContext.Response.Redirect(_webHelper.GetStoreLocation()); } }
public virtual async Task <(IEnumerable <GiftCardModel.GiftCardUsageHistoryModel> giftCardUsageHistoryModels, int totalCount)> PrepareGiftCardUsageHistoryModels(GiftCard giftCard, int pageIndex, int pageSize) { var items = new List <GiftCardModel.GiftCardUsageHistoryModel>(); foreach (var x in giftCard.GiftCardUsageHistory.OrderByDescending(gcuh => gcuh.CreatedOnUtc)) { var order = await _orderService.GetOrderById(x.UsedWithOrderId); items.Add(new GiftCardModel.GiftCardUsageHistoryModel { Id = x.Id, OrderId = x.UsedWithOrderId, OrderNumber = order != null ? order.OrderNumber : 0, UsedValue = _priceFormatter.FormatPrice(x.UsedValue, true, false), CreatedOn = _dateTimeHelper.ConvertToUserTime(x.CreatedOnUtc, DateTimeKind.Utc) }); } return(items.Skip((pageIndex - 1) * pageSize).Take(pageSize), items.Count); }
public IActionResult Generate(int orderId) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageWidgets)) { return(AccessDeniedView()); } var order = _orderService.GetOrderById(orderId); byte[] bytes; using (var stream = new MemoryStream()) { _generateReturnFormService.CreateDocument(order, stream); bytes = stream.ToArray(); } return(File(bytes, MimeTypes.ApplicationPdf, $"order_{order.Id}.pdf")); }
/// <summary> /// Lists details about Order /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task<IActionResult> Details(int? id) { if (id == null) { return NotFound(); } // bring in orders and order line items ViewBag.UserName = User.FindFirstValue(ClaimTypes.Name); ViewBag.StoreId = User.FindFirstValue(ClaimTypes.NameIdentifier); var order = await _orderService.GetOrderById(id); var products = await _productRepository.GetAllAsync(); var orderDetailVM = new OrderDetailViewModel { Order = order, Products = products }; return View(orderDetailVM); }
public static VendorPayoutListModel ToListModel(this VendorPayout Payout, IOrderService _orderService) { var model = new VendorPayoutListModel() { CommissionPercentage = Payout.CommissionPercentage, Id = Payout.Id, OrderId = Payout.OrderId, PayoutDate = Payout.PayoutDate, PayoutStatus = Payout.PayoutStatus, Remarks = Payout.Remarks, VendorId = Payout.VendorId, VendorOrderTotal = Payout.VendorOrderTotal, PayoutStatusName = Payout.PayoutStatus.ToString() }; if (_orderService != null) { var order = _orderService.GetOrderById(Payout.OrderId); model.OrderId = order.Id; } return model; }
public static VendorPayoutModel ToModel(this VendorPayout Payout, IOrderService _orderService) { var model = new VendorPayoutModel() { CommissionPercentage = Payout.CommissionPercentage, Id = Payout.Id, OrderId = Payout.OrderId, PayoutDate = Payout.PayoutDate, PayoutStatus = Payout.PayoutStatus, Remarks = Payout.Remarks, VendorId = Payout.VendorId, VendorOrderTotal = Payout.VendorOrderTotal, ShippingCharge = Payout.ShippingCharge, PayoutStatusName = Payout.PayoutStatus.ToString(), }; if (Payout.PayoutStatus == PayoutStatus.Cancelled) { model.CommissionAmount = 0; model.PayoutAmount = 0; model.VendorOrderTotal = 0; } else if (_orderService != null) { var order = _orderService.GetOrderById(Payout.OrderId); model.OrderDate = order.CreatedOnUtc; /* var vendorItemTotalExShipping = Payout.VendorOrderTotal - model.ShippingCharge; var vendorItemTotalOriginal = (vendorItemTotalExShipping * 100) / (100 + Payout.CommissionPercentage); decimal commission = vendorItemTotalExShipping - vendorItemTotalOriginal; model.CommissionAmount = commission; model.PayoutAmount = vendorItemTotalOriginal;*/ model.PayoutAmount = GetPayoutAmount(Payout.VendorOrderTotal,Payout.CommissionPercentage); model.CommissionAmount = model.VendorOrderTotal - model.PayoutAmount; } return model; }