Merged PR 53635: Add Order and OrderDetails Models and Service...
4bca3d19
Claudiu Toderas
committed
succeeded
5 changed files
IProductionOrderService.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Interfaces/IProductionOrderService.cs+26
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Interfaces/IProductionOrderService.cs
Add comment 1 Plus  using System.Collections.Generic;
Add comment 2 Plus  using System.Threading.Tasks;
Add comment 3 Plus  
Add comment 4 Plus  namespace HomagGroup.DigitalFactory.ApiGateway.Client.Interfaces
Add comment 5 Plus  {
Add comment 6 Plus   /// <summary>
Add comment 7 Plus   ///
Add comment 8 Plus   /// </summary>
Add comment 9 Plus   public interface IProductionOrderService
Add comment 10 Plus   {
Add comment 11 Plus   /// <summary>
Add comment 12 Plus   /// Get Orders
Add comment 13 Plus   /// </summary>
Add comment 14 Plus   /// <returns></returns>
Add comment 15 Plus   Task<IEnumerable<Order>> GetOrdersAsync();
Add comment 16 Plus  
Add comment 17 Plus   /// <summary>
Add comment 18 Plus   /// Get Specific Order
Add comment 19 Plus   /// </summary>
Add comment 20 Plus   /// <param name="orderId"></param>
Add comment 21 Plus   /// <param name="withParts"></param>
Add comment 22 Plus   /// <returns></returns>
Add comment 23 Plus   Task<OrderDetails> GetOrderDetailsAsync(string orderId, bool withParts);
Add comment 24 Plus   }
Add comment 25 Plus  }
Add comment 26 Plus  
ProductionOrderService.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Services/ProductionOrderService.cs+77
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Services/ProductionOrderService.cs
Add comment 1 Plus  using HomagGroup.DigitalFactory.ApiGateway.Client.Interfaces;
Add comment 2 Plus  using Newtonsoft.Json;
Add comment 3 Plus  using System;
Add comment 4 Plus  using System.Collections.Generic;
Add comment 5 Plus  using System.Globalization;
Add comment 6 Plus  using System.Net.Http;
Add comment 7 Plus  using System.Net.Http.Headers;
Add comment 8 Plus  using System.Threading.Tasks;
Add comment 9 Plus  
Add comment 10 Plus  namespace HomagGroup.DigitalFactory.ApiGateway.Client.Services
Add comment 11 Plus  {
Add comment 12 Plus   /// <summary>
Add comment 13 Plus   /// a class for a production service
Add comment 14 Plus   /// </summary>
Add comment 15 Plus   public class ProductionOrderService : ServiceBase, IProductionOrderService
Add comment 16 Plus   {
Add comment 17 Plus   /// <summary>
Add comment 18 Plus   /// create a production order service object
Add comment 19 Plus   /// </summary>
Add comment 20 Plus   /// <param name="client"></param>
Add comment 21 Plus   public ProductionOrderService(HttpClient client) : base(client)
Add comment 22 Plus   {
Add comment 23 Plus   }
Add comment 24 Plus  
Add comment 25 Plus   /// <summary>
Add comment 26 Plus   ///
Add comment 27 Plus   /// </summary>
Add comment 28 Plus   /// <returns></returns>
Add comment 29 Plus   public async Task<IEnumerable<Order>> GetOrdersAsync()
Add comment 30 Plus   {
Add comment 31 Plus   var request = new HttpRequestMessage { Method = HttpMethod.Get };
Add comment 32 Plus   var uri = $"{Prefix}productions/orders";
Add comment 33 Plus  
Add comment 34 Plus   request.RequestUri = new Uri(uri, UriKind.Relative);
Add comment 35 Plus   request.Headers.AcceptLanguage.Clear();
Add comment 36 Plus   request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(CultureInfo.CurrentUICulture.Name));
Add comment 37 Plus  
Add comment 38 Plus   var response = await Client.SendAsync(request).ConfigureAwait(false);
Add comment 39 Plus   response.HandleDeprecatedMessages(request, ApiVersion, ThrowExceptionOnDeprecatedCalls, OnDeprecatedAction);
Add comment 40 Plus   response.EnsureSuccessStatusCodeWithDetails(request);
Add comment 41 Plus   var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
Add comment 42 Plus  
Add comment 43 Plus   return JsonConvert.DeserializeObject<List<Order>>(content, SerializerSettings.Default);
Add comment 44 Plus   }
Add comment 45 Plus  
Add comment 46 Plus   /// <summary>
Add comment 47 Plus   ///
Add comment 48 Plus   /// </summary>
Add comment 49 Plus   /// <param name="orderId"></param>
Add comment 50 Plus   /// <param name="withParts"></param>
Add comment 51 Plus   /// <returns></returns>
Add comment 52 Plus   /// <exception cref="NotImplementedException"></exception>
Add comment 53 Plus  
Add comment 54 Plus   public async Task<OrderDetails> GetOrderDetailsAsync(string orderId, bool withParts)
Add comment 55 Plus   {
Add comment 56 Plus   if (string.IsNullOrEmpty(orderId))
Add comment 57 Plus   {
Add comment 58 Plus   throw new ArgumentNullException(nameof(orderId));
Add comment 59 Plus   }
Add comment 60 Plus  
Add comment 61 Plus   var request = new HttpRequestMessage { Method = HttpMethod.Get };
Add comment 62 Plus   var uri = $"{Prefix}productions/orders/{orderId}?withParts={withParts}";
Add comment 63 Plus  
Add comment 64 Plus   request.RequestUri = new Uri(uri, UriKind.Relative);
Add comment 65 Plus   request.Headers.AcceptLanguage.Clear();
Add comment 66 Plus   request.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(CultureInfo.CurrentUICulture.Name));
Add comment 67 Plus  
Add comment 68 Plus   var response = await Client.SendAsync(request).ConfigureAwait(false);
Add comment 69 Plus   response.HandleDeprecatedMessages(request, ApiVersion, ThrowExceptionOnDeprecatedCalls, OnDeprecatedAction);
Add comment 70 Plus   response.EnsureSuccessStatusCodeWithDetails(request);
Add comment 71 Plus   var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
Add comment 72 Plus  
Add comment 73 Plus   return JsonConvert.DeserializeObject<OrderDetails>(content, SerializerSettings.Default);
Add comment 74 Plus   }
Add comment 75 Plus   }
Add comment 76 Plus  }
Add comment 77 Plus  
DetailedOrder.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/DetailedOrder.cs+31
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/DetailedOrder.cs
Add comment 1 Plus  
Add comment 2 Plus  using Newtonsoft.Json;
Add comment 3 Plus  using System.Collections.Generic;
Add comment 4 Plus  
Add comment 5 Plus  namespace HomagGroup.DigitalFactory.ApiGateway.Client
Add comment 6 Plus  {
Add comment 7 Plus   /// <summary>
Add comment 8 Plus   /// Detailed Order Data
Add comment 9 Plus   /// </summary>
Add comment 10 Plus   public class OrderDetails : Order
Add comment 11 Plus   {
Add comment 12 Plus   /// <summary>
Add comment 13 Plus   /// The number of parts the order contains
Add comment 14 Plus   /// </summary>
Add comment 15 Plus   [JsonProperty(Order = 7)]
Add comment 16 Plus   public int PartCounts { get; set; }
Add comment 17 Plus  
Add comment 18 Plus   /// <summary>
Add comment 19 Plus   /// The link to the order in the productionManager UI
Add comment 20 Plus   /// </summary>
Add comment 21 Plus   [JsonProperty(Order = 8)]
Add comment 22 Plus   public string Link { get; set; }
Add comment 23 Plus  
Add comment 24 Plus   /// <summary>
Add comment 25 Plus   /// List of all parts of this order
Add comment 26 Plus   /// </summary>
Add comment 27 Plus   [JsonProperty(Order = 9)]
Add comment 28 Plus   public List<OrderPart> Parts { get; set; }
Add comment 29 Plus   }
Add comment 30 Plus  }
Add comment 31 Plus  
Order.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Order.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/Order.cs
OrderPart.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/OrderPart.cs
/Client/HomagGroup.DigitalFactory.ApiGateway.Client/OrderPart.cs