i have an order service for which i have to Get a list of active orders of type IOrder…
- User
i have an order service for which i have to Get a list of active orders of type IOrder (List) then make a class of ExportOpenOrders that will use this information to form 1-Create PDF file from List containing all the relevant information 2-Display print dialog using Append.Blazor.Printing that is my order service code using DocumentFormat.OpenXml.Spreadsheet; using DocumentFormat.OpenXml.Wordprocessing; using Microsoft.Extensions.Logging; using Storz.SupplyManager.Domain.Interfaces.Repositories; using Storz.SupplyManager.Domain.Interfaces.Services; using Storz.SupplyManager.Domain.OrderAggregate;
namespace Storz.SupplyManager.Application.OrderServices { public class OrderService : IOrderService { private readonly IOrderRepository orderRepository; private readonly ILoggerFactory logFactory; private readonly ILogger logger;
public OrderService(IOrderRepository orderRepository, ILoggerFactory logFactory) { this.logFactory = logFactory; logger = logFactory.CreateLogger<OrderService>(); this.orderRepository = orderRepository; } /// <inheritdoc /> public async Task CreateOrderAsync(string userId, string partId, string room, string productionIslandNumber) { logger.LogDebug("Creating new Order with userid: {userId}, partId: {partId}, room: {room}, and productionIslandNumber: {productionIslandNumber}", userId, partId, room, productionIslandNumber); var location = new ProductionIslandLocation(room, productionIslandNumber); var orderId = Guid.NewGuid().ToString(); var newOrder = Order.CreateNewOrder(orderId, location, partId, userId, DateTime.Now, OrderStatus.Open); if (await IsOrderUniqueAsync(newOrder).ConfigureAwait(false)) { await orderRepository.AddAsync(newOrder).ConfigureAwait(false); } else { throw new InvalidOperationException("Order already exists"); } } private async Task<bool> IsOrderUniqueAsync(IOrder order) { var openOrders = await GetAllOpenOrdersAsync().ConfigureAwait(false); return openOrders .Count(openOrder => openOrder.PartId == order.PartId && openOrder.Location.Equals(order.Location)) == 0; } /// <inheritdoc /> public async Task<List<IOrder>> GetAllFinishedOrdersAsync() { var allOrders = await orderRepository.GetAllAsync().ConfigureAwait(false); return allOrders.Where(order => order.Status == OrderStatus.Finished).ToList(); } /// <inheritdoc /> public async Task<List<IOrder>> GetAllOpenOrdersAsync() { var allOrders = await orderRepository.GetAllAsync().ConfigureAwait(false); return allOrders.Where(order => order.Status == OrderStatus.Open).ToList(); } /// <inheritdoc /> public async Task MarkOrderAsFinishedAsync(string orderId) { var order = await orderRepository.GetAsync(orderId).ConfigureAwait(false); order.MarkAsFinished(); await orderRepository.UpdateAsync(order).ConfigureAwait(false); } /// <inheritdoc /> public async Task DeleteOrderAsync(string orderId) { await orderRepository.DeleteAsync(orderId); } } - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.