private void PrepareRecurringPaymentModel(RecurringPaymentModel model, RecurringPayment recurringPayment, bool includeHistory) { Guard.NotNull(model, nameof(model)); Guard.NotNull(recurringPayment, nameof(recurringPayment)); model.Id = recurringPayment.Id; model.CycleLength = recurringPayment.CycleLength; model.CyclePeriodId = recurringPayment.CyclePeriodId; model.CyclePeriodStr = recurringPayment.CyclePeriod.GetLocalizedEnum(_localizationService, _workContext); model.TotalCycles = recurringPayment.TotalCycles; model.StartDate = _dateTimeHelper.ConvertToUserTime(recurringPayment.StartDateUtc, DateTimeKind.Utc).ToString(); model.IsActive = recurringPayment.IsActive; model.NextPaymentDate = recurringPayment.NextPaymentDate.HasValue ? _dateTimeHelper.ConvertToUserTime(recurringPayment.NextPaymentDate.Value, DateTimeKind.Utc).ToString() : ""; model.CyclesRemaining = recurringPayment.CyclesRemaining; model.InitialOrderId = recurringPayment.InitialOrder.Id; var customer = recurringPayment.InitialOrder.Customer; model.CustomerId = customer.Id; model.CustomerEmail = customer.IsGuest() ? T("Admin.Customers.Guest").Text : customer.Email; model.PaymentType = _paymentService.GetRecurringPaymentType(recurringPayment.InitialOrder.PaymentMethodSystemName).GetLocalizedEnum(_localizationService, _workContext); model.CanCancelRecurringPayment = _orderProcessingService.CanCancelRecurringPayment(_workContext.CurrentCustomer, recurringPayment); if (includeHistory) { foreach (var rph in recurringPayment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc)) { var rphModel = new RecurringPaymentModel.RecurringPaymentHistoryModel(); PrepareRecurringPaymentHistoryModel(rphModel, rph); model.History.Add(rphModel); } } }
public ActionResult HistoryList(int recurringPaymentId, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageRecurringPayments)) { return(AccessDeniedView()); } var payment = _orderService.GetRecurringPaymentById(recurringPaymentId); if (payment == null) { throw new ArgumentException("No recurring payment found with the specified id"); } var historyModel = payment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc) .Select(x => { var m = new RecurringPaymentModel.RecurringPaymentHistoryModel(); PrepareRecurringPaymentHistoryModel(m, x); return(m); }) .ToList(); var gridModel = new DataSourceResult { Data = historyModel, Total = historyModel.Count }; return(Json(gridModel)); }
public async Task <IActionResult> HistoryList(string recurringPaymentId, DataSourceRequest command) { var payment = await _orderService.GetRecurringPaymentById(recurringPaymentId); if (payment == null) { throw new ArgumentException("No recurring payment found with the specified id"); } var historyModel = new List <RecurringPaymentModel.RecurringPaymentHistoryModel>(); foreach (var x in payment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc)) { var m = new RecurringPaymentModel.RecurringPaymentHistoryModel(); await PrepareRecurringPaymentHistoryModel(m, x); historyModel.Add(m); } var gridModel = new DataSourceResult { Data = historyModel, Total = historyModel.Count }; return(Json(gridModel)); }
public ActionResult HistoryList(int recurringPaymentId, GridCommand command) { var model = new GridModel <RecurringPaymentModel.RecurringPaymentHistoryModel>(); if (_permissionService.Authorize(StandardPermissionProvider.ManageOrders)) { var payment = _orderService.GetRecurringPaymentById(recurringPaymentId); var historyModel = payment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc) .Select(x => { var m = new RecurringPaymentModel.RecurringPaymentHistoryModel(); PrepareRecurringPaymentHistoryModel(m, x); return(m); }) .ToList(); model.Data = historyModel; model.Total = historyModel.Count; } else { model.Data = Enumerable.Empty <RecurringPaymentModel.RecurringPaymentHistoryModel>(); NotifyAccessDenied(); } return(new JsonResult { Data = model }); }
public IActionResult HistoryList(string recurringPaymentId, DataSourceRequest command) { var payment = _orderService.GetRecurringPaymentById(recurringPaymentId); if (payment == null) { throw new ArgumentException("No recurring payment found with the specified id"); } var historyModel = payment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc) .Select(x => { var m = new RecurringPaymentModel.RecurringPaymentHistoryModel(); PrepareRecurringPaymentHistoryModel(m, x); return(m); }) .ToList(); var gridModel = new DataSourceResult { Data = historyModel, Total = historyModel.Count }; return(Json(gridModel)); }
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 HistoryList(int recurringPaymentId, GridCommand command) { var model = new GridModel <RecurringPaymentModel.RecurringPaymentHistoryModel>(); var payment = _orderService.GetRecurringPaymentById(recurringPaymentId); var historyModel = payment.RecurringPaymentHistory.OrderBy(x => x.CreatedOnUtc) .Select(x => { var m = new RecurringPaymentModel.RecurringPaymentHistoryModel(); PrepareRecurringPaymentHistoryModel(m, x); return(m); }) .ToList(); model.Data = historyModel; model.Total = historyModel.Count; return(new JsonResult { Data = model }); }
protected virtual void PrepareRecurringPaymentHistoryModel(RecurringPaymentModel.RecurringPaymentHistoryModel model, RecurringPaymentHistory history) { if (model == null) { throw new ArgumentNullException("model"); } if (history == null) { throw new ArgumentNullException("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); }