public bool CreateOrder(int orderId, PaymentInfoModel paymentInfo) { var orderRepo = new OrderRepo(_connString); var order = orderRepo.GetOrderById(orderId).CTM(); bool paymentStatus = ProcessPayment(paymentInfo, order.Total); if (!paymentStatus) { return(false); } order.Status = orderRepo.UpdateOrderStatus(OrderStatus.Paid).CTM(); var customerRepo = new CustomerRepo(_connString); var customerInfo = customerRepo.GetCustomerById(order.CustomerID); var custAddr = customerInfo.Address; order.Products.ForEach(x => { var fedExReq = new FedExShippingRequest { DeclaredValue = x.Total, FromAddress = new FedExAddress { StreetAddress = "1234 St", City = "OKC", State = "OK", Country = "US", AreaCode = 12345 }, ToAddress = new FedExAddress { StreetAddress = custAddr.Street, City = custAddr.City, State = custAddr.State, Country = "US", AreaCode = custAddr.ZIP }, Weight = x.Weight, Height = x.Height, Length = x.Length, Width = x.Width, }; //vvvvvvvvVVVV x.ShippingGuid = new FedExService(_fedExLicense).CreateNewShipment(fedExReq); }); order.Status = orderRepo.UpdateOrderStatus(OrderStatus.Shipped).CTM(); return(true); }
public List <ProductModel> CreateShipments(List <ProductModel> products, Models.AddressModel addr) { products.ForEach(x => { var fedExReq = new FedExShippingRequest { DeclaredValue = x.Total, FromAddress = new FedExAddress { StreetAddress = "1234 St", City = "OKC", State = "OK", Country = "US", AreaCode = 12345 }, ToAddress = new FedExAddress { StreetAddress = addr.Street, City = addr.City, State = addr.State, Country = "US", AreaCode = addr.ZIP }, Weight = x.Weight, Height = x.Height, Length = x.Length, Width = x.Width, }; x.ShippingGuid = _fedExService.CreateNewShipment(fedExReq); }); return(products); }