public DeliveryOrderDto deliveryOrder(string orderId) { Service service = ServiceDiscovery.lookup("postgres"); if (service == null) { return(null); } using (var connection = new NpgsqlConnection($"Host={service.Address};Port={service.Port};Username=postgres;Password=postgres;Database=vec_mobility_db")) { connection.Open(); //connection.Execute("Insert into Employee (first_name, last_name, address) values ('John', 'Smith', '123 Duane St');"); var value = connection.Query <string>("Select * from journeys;"); Console.WriteLine(value.First()); } if (orderId != null) { DeliveryOrderDto order = new DeliveryOrderDto(); order.Id = orderId; order.Recipient = "*****@*****.**"; return(order); } return(null); }
public IActionResult Get(string id) { if (id != null) { DeliveryOrderDto order = ShippingService.deliveryOrder(id); if (order != null) { return(Ok(order)); } } return(BadRequest()); }
public void Should_Success_Instantiate_Second() { List <DeliveryOrderDto> deliveryOrders = new List <DeliveryOrderDto>(); DeliveryOrderDto deliveryOrder = new DeliveryOrderDto("doNo", 1, "paymentBill", "billNo", 1, 1); deliveryOrders.Add(deliveryOrder); InvoiceDto viewModel = new InvoiceDto("invoiceNo", DateTimeOffset.Now, "productNames", 1, "categoryName", "paymentMethod", 1, "deliveryOrdersNo", "billsNo", "paymentBills", 1, true, true, true, true, 1, 1, deliveryOrders); Assert.NotEqual(0, viewModel.Amount); Assert.NotEqual(0, viewModel.TotalAmount); Assert.Equal(1, viewModel.Id); Assert.NotNull(viewModel); }