public IActionResult GetOrders() { var orders = _orderService.GetOrders(_userManager.GetUserId(User)); var orderListModel = new List <OrderListDto>(); OrderListDto orderModel; foreach (var order in orders) { orderModel = new OrderListDto(); orderModel.OrderId = order.Id; orderModel.OrderNumber = order.OrderNumber; orderModel.OrderDate = order.OrderDate; orderModel.OrderItems = order.OrderItems.Select(i => new OrderItemDto() { OrderItemId = i.Id, Name = i.Product.Name, Price = i.Price, Quantity = i.Quantity, }).ToList(); orderListModel.Add(orderModel); } return(View(orderListModel)); }
public virtual void InsertAndDeleteOrderListCommandTest() { string newOrderId = Guid.NewGuid().ToString(); var newOrderList = new OrderListDto { orderid = newOrderId, mallid = "8740ae06-39d2-4a9e-a02d-e227e6cc7365", buyercrmid = "W0812468", status = 0, buyercontactaccid = "c40930c6-b913-4afc-b03f-5df39241084f", iscommission = 0, buyerwmid = 0, orderno = "20171010132019169" }; var addResult = this.orderService.HandlerCommand( new InsertOrderListCommand { orderList = newOrderList }); Assert.IsNotNull(addResult); Assert.AreEqual(0, addResult.isdel); var delResult = this.orderService.HandlerCommand( new DeleteOrderByIdCommand { id = newOrderId }); Assert.IsNotNull(delResult); Assert.AreEqual(1, delResult.isdel); }
public async void GetOrderDishes_ShouldReturnExpectedList() { //Arrange var fakeOrderService = A.Fake <IOrderService>(); OrderListDto expectedDto = new OrderListDto(); List <string> dtoList = new List <string>(); dtoList.Add("eggs, toast, coffee(x3)"); dtoList.Add("steak, potato, wine, cake"); expectedDto.RawOrderResponseList = dtoList; A.CallTo(() => fakeOrderService.GetRawOrderResponseList()) .Returns(Task.FromResult(expectedDto.RawOrderResponseList)); var orderController = new OrderController(fakeOrderService); //Act var result = await orderController.GetOrderDishes(); var responseDto = result as OrderListDto; //Assert Assert.Equal(responseDto.RawOrderResponseList, expectedDto.RawOrderResponseList); }
public async Task <OrderListDto> GetOrderDishes() { OrderListDto orderListDto = new OrderListDto(); orderListDto.RawOrderResponseList = await _orderService.GetRawOrderResponseList(); return(orderListDto); }
private void dgOrders_SelectionChanged(object sender, EventArgs e) { DataGridView grid = (DataGridView)sender; if (grid.DataSource != null) { if (grid.SelectedRows.Count > 0) { _selectOrderDto = (OrderListDto)grid.CurrentRow.DataBoundItem; } } }
/// <summary> /// 初始化订单列表Dto /// </summary> /// <param name="order"></param> /// <returns></returns> private async Task <OrderListDto> PrepareOrderListDto(Order order) { var store = await _storeManager.GetByIdAsync(order.StoreId); OrderListDto dto = new OrderListDto() { Id = order.Id, OrderNumber = order.OrderNumber, OrderStatus = order.OrderStatus, OrderStatusString = order.OrderStatus.GetLocalizedEnum(_localizationManager), ShippingStatus = order.ShippingStatus, ShippingStatusString = order.ShippingStatus.GetLocalizedEnum(_localizationManager), PaymentStatus = order.PaymentStatus, PaymentStatusString = order.PaymentStatus.GetLocalizedEnum(_localizationManager), OrderSource = order.OrderSource, OrderSourceString = order.OrderSource.GetLocalizedEnum(_localizationManager), OrderTypeString = order.OrderType.GetLocalizedEnum(_localizationManager), OrderType = order.OrderType, AdminComment = order.AdminComment, CustomerComment = order.CustomerComment, Store = store?.Name ?? string.Empty, TotalAmount = order.TotalAmount, CreateOn = order.CreationTime, ShippingName = order.ShippingName, ShippingPhoneNumber = order.ShippingPhoneNumber, ShippingAddress = $"{order.ShippingProvince}{order.ShippingCity}{order.ShippingDistrict}{order.ShippingAddress}" }; foreach (var item in order.Items) { var product = await _productManager.GetByIdAsync(item.ProductId); await _productManager.ProductRepository.EnsureCollectionLoadedAsync(product, p => p.Pictures); var itemDto = new OrderListItemDto() { Id = item.Id, UnitPrice = item.UnitPrice, Price = item.Price, PictureUrl = await product.GetProductDefaultPictureUrl(item.AttributesJson, _pictureManager, _productAttributeParser), ProductName = product.Name, Quantity = item.Quantity, AttributeDesciption = GetOrderProductDescription(item) }; dto.Items.Add(itemDto); } return(dto); }
public async Task <bool> UpdateInvoiceOrder(OrderListDto orderDto) { var model = _orderRepository.FirstOrDefault(t => t.AccountNo == orderDto.AccountNo && t.CustomerFirstName == orderDto.CustomerFirstName); bool exist = false; if (model != null) { model.PaymentStatusId = (int)PaymentStatusEnum.Done; await _orderRepository.UpdateAsync(model); exist = true; } return(exist); }
private void DgMyOrdersGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { // Compare the column to the column you want to format if (this.dgMyOrdersGrid.Columns[e.ColumnIndex].Name == "colRecieved") { //get the IChessitem you are currently binding, using the index of the current row to access the datasource OrderListDto item = (OrderListDto)dgMyOrdersGrid.Rows[e.RowIndex].DataBoundItem; //check the condition if (item.Recieved == true) { dgMyOrdersGrid.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Cornsilk; } } }
public async Task <IActionResult> CreateOrderList(OrderListDto model) { try { await _orderListRepository.AddOrderListing(model.OrderListings); var status = true; return(Ok(status)); } catch (Exception ex) { var status = false; return(BadRequest(status)); } }
private List <OrderDto> orderlist([FromBody] OrderFilterDto filter) { _context.ChangeTracker.QueryTrackingBehavior = Microsoft.EntityFrameworkCore.QueryTrackingBehavior.NoTracking; OrderListDto orderListDto = new OrderListDto(); var orderList = (from o in _context.Orders join i in _context.Invoices on o.InvoiceNumber equals i.InvoiceNumber into oi from i in oi.DefaultIfEmpty() join si in _context.ShippingInfo on o.Id equals si.orderId into sio from si in sio.DefaultIfEmpty() where o.CardId == filter.userId //&& (filter.paid != null ? i.Paid == filter.paid : true) //&& (filter.status != null ? i.Status == filter.status : true) //&& (filter.start != null ? o.RecordDate >= filter.start : true) && (filter.end != null ? o.RecordDate <= filter.end : true) //&& (filter.keyword != null ? i.InvoiceNumber.ToString().Contains(filter.keyword) || o.PoNumber.ToString().Contains(filter.keyword) : true) select new OrderDto { id = o.Id, card_id = o.CardId, branch = o.Branch, po_number = o.PoNumber, status = _isettings.getOrderStatus(Convert.ToInt32(o.Status)), //o.Status.ToString(), invoice_number = o.InvoiceNumber, TotalAmount_GstIncl = i.Total, TotalAmount_GSTExcl = i.Price, GstAmount = i.Tax, record_date = o.RecordDate, shipto = o.Shipto, special_shipto = o.SpecialShipto, date_shipped = o.DateShipped, freight = o.Freight, ticket = o.Ticket, shipping_method = o.ShippingMethod, payment_type = o.PaymentType, paid = _iorder.getOrderPaymentStatus(o.Id), //o.Paid, receiver_name = si.receiver, receiver_phone = si.receiver_phone, is_web_order = true, freightInfo = _iorder.getSupplierShippingInfo(o.Id), web_order_status = o.WebOrderStatus }).ToList(); return(orderList); }
public List <OrderListDto> GetOrdersByUser(GuidRequest request) { var responseGroup = orderRepository.FindAll(x => x.UserGuid == request.Guid).GroupBy(x => x.OrderGuid).ToList(); var list = new List <OrderListDto>(); foreach (var group in responseGroup) { var orderList = new OrderListDto(); orderList.Orders = new List <MenuDto>(); var restaurant = restaurantRepository.FindAll(x => x.Guid == group.FirstOrDefault().RestaurantGuid).FirstOrDefault(); if (restaurant != null) { orderList.RestaurantGuid = restaurant.Guid; orderList.RestaurantName = restaurant.Name; orderList.RestaurantDescription = restaurant.Description; orderList.RestaurantLogo = restaurant.Logo; orderList.OrderGuid = group.FirstOrDefault().OrderGuid; orderList.Status = (int)group.FirstOrDefault().Status; orderList.Date = group.FirstOrDefault().DateCreated; orderList.IsCommted = group.FirstOrDefault().IsCommeted; foreach (var item in group) { var menu = menuRepository.FindAll(x => x.Guid == item.MenuGuid).FirstOrDefault(); orderList.Orders.Add(new MenuDto { Guid = menu.Guid, Name = menu.Name, Description = menu.Description, Logo = menu.Logo, Amount = menu.Amount, Count = menu.Count, Type = (int)menu.Type, RestaurantGuid = menu.RestaurantGuid }); } list.Add(orderList); } } return(list.OrderByDescending(x => x.Date).Take(5).ToList()); }
public ActionResult <OrderListDto> GetAll(int page = 1, int size = 10) { try { var orders = _service.GetAllOrders(page, size); int total = _service.TotalOrders; string next = string.Empty; if (page * size < total) { next = Url.Action(nameof(GetAll), new { page = page + 1, size = size }); } var data = _mapper.Map <IEnumerable <Order>, IEnumerable <OrderDto> >(orders); var response = new OrderListDto { Data = data, Next = next, Total = total }; return(Ok(response)); } catch (ArgumentOutOfRangeException) { return(BadRequest()); } }
private List <OrderDto> orderlist([FromBody] OrderFilterDto filter) { _context.ChangeTracker.QueryTrackingBehavior = Microsoft.EntityFrameworkCore.QueryTrackingBehavior.NoTracking; OrderListDto orderListDto = new OrderListDto(); var orderList = (from o in _context.Orders join i in _context.Invoice on o.InvoiceNumber equals i.InvoiceNumber into oi from i in oi.DefaultIfEmpty() join si in _context.ShippingInfo on o.Id equals si.orderId into sio from si in sio.DefaultIfEmpty() where o.CardId == filter.id //&& (filter.paid != null ? i.Paid == filter.paid : true) //&& (filter.status != null ? i.Status == filter.status : true) //&& (filter.start != null ? o.RecordDate >= filter.start : true) && (filter.end != null ? o.RecordDate <= filter.end : true) //&& (filter.keyword != null ? i.InvoiceNumber.ToString().Contains(filter.keyword) || o.PoNumber.ToString().Contains(filter.keyword) : true) select new OrderDto { id = o.Id, card_id = o.CardId, branch = o.Branch, po_number = o.PoNumber, status = _isettings.getOrderStatus(Convert.ToInt32(o.Status)), //o.Status.ToString(), invoice_number = o.InvoiceNumber, TotalAmount_GstIncl = i.Total, TotalAmount_GSTExcl = i.Price, GstAmount = i.Tax, record_date = o.RecordDate, shipto = o.Shipto, special_shipto = o.SpecialShipto, date_shipped = o.DateShipped, freight = o.Freight, ticket = o.Ticket, shipping_method = o.ShippingMethod, payment_type = o.PaymentType, paid = _iorder.getOrderPaymentStatus(o.Id), //o.Paid, receiver_name = si.receiver, receiver_phone = si.receiver_phone, is_web_order = true, freightInfo = _iorder.getSupplierShippingInfo(o.Id), web_order_status = o.WebOrderStatus }).ToList() ; //var itemCount = orderList.Count(); //var pageCount = (int)Math.Ceiling(itemCount / (double)pagination.PageSize); //var finalList = // orderList // .Skip((pagination.PageNumber - 1) * pagination.PageSize) // .Take(pagination.PageSize); //foreach (var o in orderList) //{ // try // { // if (o.web_order_status == 0) // o.web_order_status = 1; // o.status = getOrderStatus(o.web_order_status); // } // catch (Exception ex) // { // _logger.LogCritical($"error occur when changing order status!",ex); // } //} //orderListDto.Orders = finalList; //orderListDto.CurrentPage = pagination.PageNumber; //orderListDto.PageSize = pagination.PageSize; //orderListDto.PageCount = pageCount; //orderListDto.ItemCount = itemCount; return(orderList); }
public List <OrderListDto> ReadInvoiceFile(IFormFile formFile) { List <OrderListDto> orderDtoList = new List <OrderListDto>(); int row = 0; System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); int cont = 1; int customerFirstName = 0; int accountNo = 0; using (var reader = ExcelReaderFactory.CreateReader(formFile.OpenReadStream())) { while (reader.Read()) //Each ROW { if (row == 0) //read column numbers { for (int column = 0; column < reader.FieldCount; column++) { if (getValue(reader, column) == L("CustomerName")) { customerFirstName = column; } if (getValue(reader, column) == L("Account")) { accountNo = column; } } } else { OrderListDto orderDto = new OrderListDto(); for (int column = 0; column < reader.FieldCount; column++) { if (column == customerFirstName) { orderDto.CustomerFirstName = getValue(reader, column); } if (column == accountNo) { orderDto.AccountNo = getValue(reader, column); } } if (orderDto.AccountNo != null) { orderDto.Id = cont++; orderDtoList.Add(orderDto); } } row++; } } foreach (var item in orderDtoList) { if (UpdateInvoiceOrder(item).Result) { item.Notes = L("Loaded"); } else { item.Notes = L("NoFounded"); } } return(orderDtoList); }
public OrderListDto GetOrderList(int pageIndex, int pageSize) { var orders = Enumerable.Empty <SharedLibrary.Entity.Order>(); var orderDetails = Enumerable.Empty <int>(); var totalCount = 0; using (var connection = new SqlConnection(_configurationService.ConnectionString("Northwind"))) { var sql = @" DECLARE @OrderIds table ( OrderID int ) INSERT INTO @OrderIds(OrderID) SELECT OrderID FROM dbo.Orders ORDER BY OrderID OFFSET @skipCount ROWS FETCH NEXT @pageSize ROWS ONLY; SELECT * FROM dbo.Orders o JOIN @OrderIds oIds ON oIds.OrderID = o.OrderID SELECT od.OrderID FROM dbo.[Order Details] od JOIN @OrderIds oIds ON oIds.OrderID = od.OrderID SELECT count(0) FROM dbo.Orders "; var dynamicParameters = new DynamicParameters(); dynamicParameters.Add("skipCount", pageIndex * pageSize, DbType.Int32); dynamicParameters.Add("pageSize", pageSize, DbType.Int32); var gridReader = connection.QueryMultiple(sql, dynamicParameters); orders = gridReader.Read <SharedLibrary.Entity.Order>(); orderDetails = gridReader.Read <int>(); totalCount = gridReader.Read <int>().FirstOrDefault(); } var orderDetailCount = orderDetails.GroupBy(od => od) .ToDictionary(od => od.Key, od => od.Count()); var result = new OrderListDto { TotalCount = totalCount, Items = orders.Select(o => { return(new OrderListItemDto { OrderID = o.OrderID, CustomerID = o.CustomerID, EmployeeID = o.EmployeeID, OrderDate = o.OrderDate, RequiredDate = o.RequiredDate, ShippedDate = o.ShippedDate, ShipVia = o.ShipVia, Freight = o.Freight, ShipName = o.ShipName, ShipAddress = o.ShipAddress, ShipCity = o.ShipCity, ShipRegion = o.ShipRegion, ShipPostalCode = o.ShipPostalCode, ShipCountry = o.ShipCountry, DetailCount = orderDetailCount.GetValue(o.OrderID) }); }).ToArray() }; return(result); }