public void Write_Then_Read_Order() { var order = new ApiOrder() { OrderId = 9998990005, MerchantOrderId = 12, Amount = 29990, CurrencyCode = "EUR", CountryCode = "DK", LanguageCode = "dn" }; var sb = new StringBuilder(); order.AddToStringBuilder(sb); var orderAsString = sb.ToString(); var order2 = new ApiOrder(new ModifiedXmlDocument(orderAsString), string.Empty); Assert.AreEqual(order.OrderId, order2.OrderId); Assert.AreEqual(order.MerchantOrderId, order2.MerchantOrderId); Assert.AreEqual(order.Amount, order2.Amount); Assert.AreEqual(order.CurrencyCode, order2.CurrencyCode); Assert.AreEqual(order.CountryCode, order2.CountryCode); Assert.AreEqual(order.LanguageCode, order2.LanguageCode); }
public ApiOrder Add(ApiOrder apiOrder) { db.Orders.Add(Mapper.Map <ApiOrder, Order>(apiOrder)); apiOrder.OrderID = db.SaveChanges(); return(apiOrder); }
public InsertOrderWithPayment() : base("INSERT_ORDERWITHPAYMENT") { Order = new ApiOrder(); Payment = new ApiPayment(); Params.Parameters.Add(Order); Params.Parameters.Add(Payment); }
public async Task <ApiResponseBase> Post([FromBody] ApiOrder product) { var user = await GetCurrentUserAsync().ConfigureAwait(false); var isAdmin = await _userManager.IsInRoleAsync(user, UserRole.Admin).ConfigureAwait(false); isAdmin = isAdmin || await _userManager.IsInRoleAsync(user, UserRole.AdminAssistant).ConfigureAwait(false); await _repo.UpdateAsync(user.Id, isAdmin, product); return(new ApiResponseBase()); }
public ApiOrder Post([FromBody] ApiOrder apiOrder) { try { apiOrder = service.Add(apiOrder); } catch (Exception ex) { throw ex; } return(apiOrder); }
public void Read_Order() { var doc = new ModifiedXmlDocument(OrderText); var order = new ApiOrder(doc, string.Empty); Assert.AreEqual(9998990005, order.OrderId); Assert.AreEqual(29990, order.Amount); Assert.AreEqual("EUR", order.CurrencyCode); Assert.AreEqual("NL", order.CountryCode); Assert.AreEqual("nl", order.LanguageCode); Assert.IsFalse(order.MerchantOrderId.HasValue); }
public ApiOrder Put([FromBody] ApiOrder apiOrder) { try { int?id = apiOrder.OrderID; apiOrder = service.Update(id, apiOrder); } catch (Exception ex) { throw ex; } return(new ApiOrder()); }
public void Can_Add_Extra_Data_To_Order() { // Arrange var order = new ApiOrder { OrderId = 123, LanguageCode = "da", MerchantReference = "JustMyLuck" }; // Act order.AddExtraData("Ucommerce", "ECOM"); var text = ConvertApiDataPartToString(order); // Assert Assert.IsTrue(text.Contains("<ECOM>Ucommerce</ECOM>")); }
public ApiOrder Update(int?id, ApiOrder apiOrder) { var orderInDB = db.Orders.Where(o => o.OrderID == id).FirstOrDefault(); if (orderInDB != null) { apiOrder.OrderID = orderInDB.OrderID; orderInDB = Mapper.Map <ApiOrder, Order>(apiOrder); db.Entry(orderInDB).State = System.Data.EntityState.Modified; db.SaveChanges(); } return(apiOrder); }
public ApiOrder GetSingle(int?id) { ApiOrder apiOrder = new ApiOrder(); try { apiOrder = service.GetSingle(id); } catch (Exception ex) { throw ex; } return(apiOrder); }
/// <summary> /// Orderings the apply. /// </summary> /// <param name="swaggerDoc">The swagger document.</param> /// <param name="schemaRegistry">The schema registry.</param> /// <param name="apiExplorer">The API explorer.</param> internal static void OrderingApply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer) { var paths = swaggerDoc.paths; if (paths == null || !paths.Any()) { return; } var tagGroups = new Dictionary <string, IList <ApiOrder> >(); foreach (var path in paths) { var key = GetInvokeMethod(path.Value, out var tag); var apiKey = $"{key}{path.Key.TrimStart('/')}"; var apiFound = apiExplorer.ApiDescriptions.FirstOrDefault(c => c.ID.StartsWith(apiKey)); if (!tagGroups.ContainsKey(tag)) { tagGroups.Add(tag, new List <ApiOrder>()); } var item = new ApiOrder { Order = GetApiOrder(apiFound), PathKey = path.Key, PathValue = path.Value, OperationName = tag }; tagGroups[tag].Add(item); tagGroups[tag] = tagGroups[tag].OrderBy(c => c.Order).ToList(); } var list = new List <ApiOrder>(); foreach (var tagGroup in tagGroups) { list.AddRange(tagGroup.Value); } swaggerDoc.paths = list.OrderBy(c => c.OperationName).ToDictionary(c => c.PathKey, c => c.PathValue); }
public async Task <ActionResult <ApiOrder> > GetOrder(int id) { ApiOrder apiOrder = new ApiOrder(); using (_context) { //Gets the overview of the order with the select id. apiOrder.order = await _context.OrderOverview.FindAsync(id); //Gets all items associated with the order. var orderQuery = from item in _context.OrderItem where item.OrderId == id select item; apiOrder.items = orderQuery.ToList(); } if (apiOrder.order == null) { return(NotFound()); } //Returns the apiOrder - which includes the orderoverview and order items. return(apiOrder); }
/// <summary> /// Processes the item method ordering. /// </summary> /// <param name="group">The group.</param> /// <param name="apiExplorer">The API explorer.</param> /// <returns>IDictionary<System.String, PathItem>.</returns> private static IDictionary <string, PathItem> ProcessItemMethodOrdering(IDictionary <string, PathItem> group, IApiExplorer apiExplorer) { var tagGroups = new Dictionary <string, IList <ApiOrder> >(); foreach (var path in group) { var key = GetInvokeMethod(path.Value, out var tag); var apiKey = $"{key}{path.Key.TrimStart('/')}"; var apiFound = apiExplorer.ApiDescriptions.FirstOrDefault(c => c.ID.StartsWith(apiKey)); if (!tagGroups.ContainsKey(tag)) { tagGroups.Add(tag, new List <ApiOrder>()); } var item = new ApiOrder { Order = GetApiOrder(apiFound), PathKey = path.Key, PathValue = path.Value, OperationName = tag }; tagGroups[tag].Add(item); tagGroups[tag] = tagGroups[tag].OrderBy(c => c.Order).ToList(); } var list = new List <ApiOrder>(); foreach (var tagGroup in tagGroups) { list.AddRange(tagGroup.Value); } return(list.OrderBy(c => c.OperationName).ToDictionary(c => c.PathKey, c => c.PathValue)); }
public ApiOrder Post([FromBody] ApiOrder apiorder) { return(apiorder); }
public ApiOrder Update(int?id, ApiOrder order) { return(factory.OrderDAO.Update(id, order)); }
public GetOrderStatus() : base("GET_ORDERSTATUS") { Order = new ApiOrder(); Params.Parameters.Add(Order); }
private static Order MapOrder(ApiOrder apiOrder) => Order.Create(apiOrder.Id, apiOrder.Lines.Select(MapOrderLine).ToList());
public ApiOrder Add(ApiOrder order) { return(factory.OrderDAO.Add(order)); }
public GetOrder() : base("GET_ORDER") { Order = new ApiOrder(); Params.Parameters.Add(Order); }
protected OrderAdapter(ApiMarketGateway marketGateway, ApiOrder apiOrder) { this.apiOrder = apiOrder; this.MarketGateway = marketGateway; }
public async Task UpdateAsync(string userId, bool isAdmin, ApiOrder it) { await using var context = _di.GetRequiredService <ApplicationDbContext>(); var order = await context.Orders.FindAsync(it.Id); if (order != null) { if (order.Status == OrderStatus.Canceled) { throw new ArgumentException("Замовлення скасоване і не може редагуватися"); } order.ClientName = it.ClientName; order.ClientAddress = it.ClientAddress; order.ClientPhone = it.ClientPhone; order.OrderNumber = it.OrderNumber; order.Other = it.Other; order.Status = it.Status ?? OrderStatus.Open; order.Payment = it.Payment; if (it.Status == OrderStatus.Delivered && order.CloseDate == null) { order.CloseDate = DateTime.UtcNow; } if (it.Status == OrderStatus.Canceled && order.CanceledDate == null) { order.CanceledDate = DateTime.UtcNow; order.CanceledByUserId = userId; } var note = order.ResponsibleUserId != userId ? "Відредаговано іншим продавцем" : null; var operation = OrderOperation.Created; if (order.Id != 0) { switch (order.Status) { case OrderStatus.Canceled: operation = OrderOperation.Canceled; break; case OrderStatus.Delivered: operation = OrderOperation.Closed; break; default: operation = OrderOperation.Updated; break; } } order.OrderEditions = new List <OrderAction>(new[] { new OrderAction { Date = DateTime.UtcNow, OrderId = order.Id, UserId = userId, Note = note, Operation = operation, OrderJson = JsonConvert.SerializeObject(it) } }); it.Products = null; // we do not want to sent this back to the client. await Informer.OrderChangedAsync(new[] { new ApiOrderDetailsChange { OrderId = order.Id, Order = it, ChangeTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() } }).ConfigureAwait(false); } await context.SaveChangesAsync().ConfigureAwait(false); }
public CancelOrder() : base("CANCEL_ORDER") { Order = new ApiOrder(); Params.Parameters.Add(Order); }
public ApiOrder Put(int?id, [FromBody] ApiOrder apiorder) { return(apiorder); }