public bool PlaceOrder(Order order, int customerId) { try { Customer customer = CustomerRepository.Load(customerId); if (order.Amount == 0) { return(false); } if (customer.Country.Equals(AnyCompanyHelpers.CountryNames.UK)) { order.VAT = 0.2d; } else { order.VAT = 0; } orderRepository.Save(order); return(true); } catch (Exception ex) { return(false); } }
public bool PlaceOrder(Order order, int customerId) { try { using (OrderRepository orderRepository = new OrderRepository()) { Customer customer = GetCustomer(customerId); if (order.Amount == 0) { return(false); } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } orderRepository.Save(order); return(true); } } catch (Exception Ex) { throw Ex; } }
public bool PlaceOrder(Order order, int customerId) { Customer customer = CustomerRepository.Load(customerId); if (customer == null) { throw new CustomerNotFoundException("Customer with Id " + customerId + " Not Found"); } if (order.Amount == 0) { return(false); } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } //Create a new order ref, this case a Guid should do even though its not ideal order.OrderNo = Guid.NewGuid().ToString(); return(orderRepository.Save(order));; }
public bool PlaceOrder(IOrder order, Guid customerId) { var customer = CustomerRepository.Load(customerId); if (order.Amount < 0.0) { return(false); } order.VAT = customer.Country == "UK" ? Properties.Settings.Default.ukVat : Properties.Settings.Default.otherVat; order.CustomerId = customerId; orderRepository.Save(order); return(true); }
public bool PlaceOrder(Order order, int customerId) { Customer customer = null; try { if (order == null || customerId <= 0) { return(false); } customer = CustomerRepository.Load(customerId); if (customer == null) { return(false); } if (order.Amount == 0) { return(false); } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } order.CustomerId = customer.CustomerId; return(orderRepository.Save(order)); } catch (System.Exception ex) { //Write log here throw; } finally { customer = null; } }
public bool PlaceOrder(Order order) { try { Customer customer = CustomerRepository.Load(order.CustomerId); if (customer != null) { order.CustomerId = customer.CustomerId; if (order.Amount == 0) { return(false); } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } order = OrderRepository.Save(order); return(order?.OrderId > 0); } else { //To-do: Implement proper error logging Console.WriteLine("Error : Customer doesn't exist"); return(false); } } catch (Exception ex) { //To-do: Implement proper error logging Console.WriteLine("Error : " + ex.Message); return(false); } }
public bool PlaceOrder(Order order, int customerId) { if (order == null) { throw new ArgumentNullException(); } try { Customer customer = CustomerRepository.Load(customerId); if (order.Amount == 0) { return(false); } if (customer == null) { return(false); } switch (customer.Country) { case "UK": order.VAT = 0.2d; break; default: order.VAT = 0; break; } orderRepository.Save(order, customerId); return(true); } catch (Exception ex) { throw new Exception($"Failed to save order for customer with customer ID {customerId}", ex); } }
public bool PlaceOrder(Order order, int customerId) { Customer customer = CustomerRepository.Load(customerId); if (order.Amount == 0) { return(false); } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } orderRepository.Save(order); return(true); }
public bool PlaceOrder(Order order, int customerId) { try { Customer customer = CustomerRepository.Load(customerId); if (customer != null) { order.CustomerId = customerId; if (order.Amount == 0) { return(false); } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } orderRepository.Save(order); return(true); } else { return(false); } } catch (Exception ex) { Utils.LogErrorToDB(ex, "OrderService.PlaceOrder"); return(false); } }
public bool PlaceOrder(Order order, int customerId) { //verify the input if (order.Amount == 0) { return(false); } //apply business logic, based on the customer Customer customer; try { customer = CustomerRepository.Load(customerId, _customerDb); } catch (Exception exp) { //log return(false); // problem loading customer } if (customer.Country == "UK") { order.VAT = 0.2d; } else { order.VAT = 0; } order.CustomerId = customerId; _orderRepository.Save(order); return(true); }
public void SaveOrder(Order order, int customerId) { orderRepository.Save(order, customerId); }