public async Task <ActionFeedback <GetOrderVm> > GetOrderAsync(long orderId) { var order = await _orderRepository.QueryAsNoTracking() .Include(item => item.OrderItems).ThenInclude(item => item.Product).ThenInclude(item => item.ThumbnailImage) .FirstOrDefaultAsync(item => item.Id == orderId); if (order == null) { return(ActionFeedback <GetOrderVm> .Fail($"Cannot find order with id {orderId}")); } var user = await _workContext.GetCurrentUser(); var result = new GetOrderVm { OrderStatus = order.OrderStatus, CustomerId = order.CustomerId, SubTotal = order.SubTotal, SubTotalCost = order.OrderItems.Sum(item => item.Quantity * item.Product.Cost), ShippingAmount = order.ShippingAmount, ShippingCost = order.ShippingCost, Discount = order.Discount, OrderTotal = order.OrderTotal, OrderTotalCost = order.OrderTotalCost, TrackingNumber = order.TrackingNumber, CreatedById = order.CreatedById, VendorId = order.VendorId, Note = order.Note, IsShopeeOrder = order.IsShopeeOrder, OrderItems = order.OrderItems .Select(item => new OrderItemVm { Id = item.Id, ProductId = item.ProductId, ProductName = item.Product.Name, ProductSku = item.Product.Sku, ProductCost = item.Product.Cost, OriginalPrice = item.Product.Price, ProductPrice = item.ProductPrice, Stock = item.Product.Stock, ProductImage = _mediaService.GetThumbnailUrl(item.Product.ThumbnailImage), Quantity = item.Quantity }) .OrderBy(item => item.Id).ToList(), PaymentProviderId = order.PaymentProviderId, PaymentProviderList = (await _paymentProviderService.GetListAsync(true)) .Select(item => new SelectListItem { Value = item.Id.ToString(), Text = item.Description }).ToList(), CanEdit = CanEditOrder(order) }; return(ActionFeedback <GetOrderVm> .Succeed(result)); }
public async Task <IActionResult> GetPaymentList() { var payments = await _paymentProviderService.GetListAsync(true); var selectList = payments.Select(item => new SelectListItem { Value = item.Id.ToString(), Text = item.Description }); return(Json(selectList)); }
public async Task <IActionResult> Get() { var providers = await _paymentProviderService.GetListAsync(); return(Json(providers)); }