public HttpResponseMessage PlaceOrder(OrderDto newOrder) { var order = new Order { NumberOfPizzas = newOrder.NumberOfPizzas, TypeOfPizza = newOrder.TypeOfPizza, AddressForDelivery = newOrder.AddressForDelivery, NameOfCustomer = newOrder.NameOfCustomer, Cost = 10 * newOrder.NumberOfPizzas }; var orderService = new OrderPizzaService(); var success = orderService.OrderPizza(order); if (success) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not process your order, try again later...")); }
public HttpResponseMessage PlaceOrder(OrderDTO newOrder) { //take dto and map it onto one of our order objects //object initialization var order = new Order { NumberOfPizzas = newOrder.NumberOfPizzas, TypeOfPizza = newOrder.TypeOfPizza, AddressForDelivery = newOrder.AddressForDelivery, NameOfCustomer = newOrder.NameOfCustomer, Cost = 10 * newOrder.NumberOfPizzas }; var orderService = new OrderPizzaService(); var success = orderService.OrderPizza(order); if (success) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Could not process order, please try again later... ")); }