private DtoOrder FillOrder(Order dbOrder) { if (dbOrder == null) { return(null); } var order = dbOrder.ToDTO(); if (dbOrder.Client_Id != null) { order.Client = ClientQueries.GetClient(dbOrder.Client_Id.Value); } if (dbOrder.AddressToShip_Id.HasValue) { order.AddressToShip = ClientQueries.GetAddress(dbOrder.AddressToShip_Id.Value); } order.SkusRequesteds = GetRequestedSkus(dbOrder.Id); order.RequestedStores = GetRequestedStores(dbOrder.Id); order.Responses = GetOrderResponses(dbOrder.Id); return(order); }
public DtoOrder GenerateNewOrder(DtoClient dtoClient, int?lastAddress = null) { try { EnsureArg.IsNotNull(dtoClient, nameof(dtoClient)); } catch (Exception ex) { throw new BadRequest(ex); } var client = ClientQueries.GetClient(dtoClient.Token); var order = new DtoOrder() { Client = client }; DtoAddress selectedAddress = null; if (lastAddress != null) { selectedAddress = client.Addresses?.Where(i => i.Id == lastAddress)?.FirstOrDefault() ?? dtoClient.Addresses?.FirstOrDefault(); } else { order.AddressToShip = client.Addresses?.FirstOrDefault(); } return(CheckOrder(order)); }
public DtoOrder GetLastOrder(string clientToken) { try { EnsureArg.IsNotNullOrEmpty(clientToken, nameof(clientToken)); } catch (Exception ex) { throw new BadRequest(ex); } var client = ClientQueries.GetClient(clientToken); var order = GetIncompletLastOrder(client); return(order); }
public DtoOrder SetShippping(string clientToken, int addressId) { try { EnsureArg.IsNotNullOrEmpty(clientToken, nameof(clientToken)); EnsureArg.IsGt(addressId, 0, nameof(addressId)); } catch (Exception ex) { throw new BadRequest(ex); } var client = ClientQueries.GetClient(clientToken); var order = GetIncompletLastOrder(client); order.AddressToShip = client.Addresses.Where(i => i.Id == addressId).SingleOrDefault(); OrderQueries.Update(ref order); return(CheckOrder(order)); }
public void Foo() { var result = _clients.AsQueryable().Where(ClientQueries.GetClient(client.Id)); Assert.AreEqual(1, result.Count()); }