public virtual (IEnumerable <AffiliateModel.AffiliatedOrderModel> affiliateOrderModels, int totalCount) PrepareAffiliatedOrderList(Affiliate affiliate, AffiliatedOrderListModel model, int pageIndex, int pageSize) { DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); OrderStatus? orderStatus = model.OrderStatusId > 0 ? (OrderStatus?)(model.OrderStatusId) : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; ShippingStatus?shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null; var orders = _orderService.SearchOrders( createdFromUtc: startDateValue, createdToUtc: endDateValue, os: orderStatus, ps: paymentStatus, ss: shippingStatus, affiliateId: affiliate.Id, pageIndex: pageIndex - 1, pageSize: pageSize); return(orders.Select(order => { var orderModel = new AffiliateModel.AffiliatedOrderModel(); orderModel.Id = order.Id; orderModel.OrderNumber = order.OrderNumber; orderModel.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); orderModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc); return orderModel; }), orders.TotalCount); }
public ActionResult AffiliatedOrderList(int affiliateId, DataSourceRequest command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { return(AccessDeniedView()); } var affiliate = _affiliateService.GetAffiliateById(affiliateId); if (affiliate == null) { throw new ArgumentException("No affiliate found with the specified id"); } var orders = _orderService.SearchOrders(affiliateId: affiliate.Id, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult { Data = orders.Select(order => { var orderModel = new AffiliateModel.AffiliatedOrderModel(); orderModel.Id = order.Id; orderModel.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); orderModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc); return(orderModel); }), Total = orders.TotalCount }; return(Json(gridModel)); }
public ActionResult AffiliatedOrderList(int affiliateId, GridCommand command) { var model = new GridModel <AffiliateModel.AffiliatedOrderModel>(); if (_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { var affiliate = _affiliateService.GetAffiliateById(affiliateId); var orders = _orderService.GetAllOrders(affiliate.Id, command.Page - 1, command.PageSize); model.Data = orders.Select(order => { var orderModel = new AffiliateModel.AffiliatedOrderModel(); orderModel.Id = order.Id; orderModel.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); orderModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc); return(orderModel); }); model.Total = orders.TotalCount; } else { model.Data = Enumerable.Empty <AffiliateModel.AffiliatedOrderModel>(); NotifyAccessDenied(); } return(new JsonResult { Data = model }); }
public ActionResult AffiliatedOrderList(DataSourceRequest command, AffiliatedOrderListModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { return(AccessDeniedView()); } var affiliate = _affiliateService.GetAffiliateById(model.AffliateId); if (affiliate == null) { throw new ArgumentException("No affiliate found with the specified id"); } DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.StartDate.Value, _dateTimeHelper.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.EndDate.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1); var orderStatusIds = model.OrderStatusId > 0 ? new List <int>() { model.OrderStatusId } : null; var paymentStatusIds = model.PaymentStatusId > 0 ? new List <int>() { model.PaymentStatusId } : null; var shippingStatusIds = model.ShippingStatusId > 0 ? new List <int>() { model.ShippingStatusId } : null; var orders = _orderService.SearchOrders( createdFromUtc: startDateValue, createdToUtc: endDateValue, osIds: orderStatusIds, psIds: paymentStatusIds, ssIds: shippingStatusIds, affiliateId: affiliate.Id, pageIndex: command.Page - 1, pageSize: command.PageSize); var gridModel = new DataSourceResult { Data = orders.Select(order => { var orderModel = new AffiliateModel.AffiliatedOrderModel(); orderModel.Id = order.Id; orderModel.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); orderModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc); return(orderModel); }), Total = orders.TotalCount }; return(Json(gridModel)); }
public ActionResult AffiliatedOrderList(int affiliateId, GridCommand command) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageAffiliates)) { return(AccessDeniedView()); } var affiliate = _affiliateService.GetAffiliateById(affiliateId); if (affiliate == null) { throw new ArgumentException("No affiliate found with the specified id"); } //var orders = affiliate.AffiliatedOrders // .Where(o => !o.Deleted) // .OrderBy(x => x.CreatedOnUtc) // .ToList(); var orders = _orderService.GetAllOrders(affiliateId: affiliate.Id, pageIndex: command.Page - 1, pageSize: command.PageSize); var model = new GridModel <AffiliateModel.AffiliatedOrderModel> { Data = orders.PagedForCommand(command) .Select(order => { var orderModel = new AffiliateModel.AffiliatedOrderModel(); orderModel.Id = order.Id; orderModel.OrderStatus = order.OrderStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.PaymentStatus = order.PaymentStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.ShippingStatus = order.ShippingStatus.GetLocalizedEnum(_localizationService, _workContext); orderModel.OrderTotal = _priceFormatter.FormatPrice(order.OrderTotal, true, false); orderModel.CreatedOn = _dateTimeHelper.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc); return(orderModel); }), Total = orders.Count }; return(new JsonResult { Data = model }); }
public virtual async Task <(IEnumerable <AffiliateModel.AffiliatedOrderModel> affiliateOrderModels, int totalCount)> PrepareAffiliatedOrderList(Affiliate affiliate, AffiliatedOrderListModel model, int pageIndex, int pageSize) { DateTime?startDateValue = (model.StartDate == null) ? null : (DateTime?)_dateTimeService.ConvertToUtcTime(model.StartDate.Value, _dateTimeService.CurrentTimeZone); DateTime?endDateValue = (model.EndDate == null) ? null : (DateTime?)_dateTimeService.ConvertToUtcTime(model.EndDate.Value, _dateTimeService.CurrentTimeZone).AddDays(1); int? orderStatus = model.OrderStatusId > 0 ? model.OrderStatusId : null; PaymentStatus? paymentStatus = model.PaymentStatusId > 0 ? (PaymentStatus?)(model.PaymentStatusId) : null; ShippingStatus?shippingStatus = model.ShippingStatusId > 0 ? (ShippingStatus?)(model.ShippingStatusId) : null; var orders = await _orderService.SearchOrders( createdFromUtc : startDateValue, createdToUtc : endDateValue, os : orderStatus, ps : paymentStatus, ss : shippingStatus, affiliateId : affiliate.Id, pageIndex : pageIndex - 1, pageSize : pageSize); var statuses = await _orderStatusService.GetAll(); var affiliateorders = new List <AffiliateModel.AffiliatedOrderModel>(); foreach (var order in orders) { var orderModel = new AffiliateModel.AffiliatedOrderModel { Id = order.Id, OrderNumber = order.OrderNumber, OrderCode = order.Code, OrderStatus = statuses.FirstOrDefault(y => y.StatusId == order.OrderStatusId)?.Name, PaymentStatus = order.PaymentStatusId.GetTranslationEnum(_translationService, _workContext), ShippingStatus = order.ShippingStatusId.GetTranslationEnum(_translationService, _workContext), OrderTotal = await _priceFormatter.FormatPrice(order.OrderTotal, order.CustomerCurrencyCode, false, _workContext.WorkingLanguage), CreatedOn = _dateTimeService.ConvertToUserTime(order.CreatedOnUtc, DateTimeKind.Utc) }; affiliateorders.Add(orderModel); } return(affiliateorders, orders.TotalCount); }