private OrderConfirmation GetOrderConfirmation(int orderConfirmation, UserModel user) { var confirmation = new OrderConfirmation { Address =Utils.GetFormattedAddress(user.Address1, user.Address2, user.City, user.State, user.ZipCode, "USA"), OrderConfirmationNumber = orderConfirmation, Name = user.Name, Email = user.Email, Phone = user.Phone }; return confirmation; }
public ActionResult SendOrder(string things) { try { var userLogged = Session[Utils.UserKey] as UserModel; var thingsSelected = new JavaScriptSerializer().Deserialize<IEnumerable<MarketingMaterialSelection>>(things); var positiveSelection = thingsSelected.Where(selected => selected.Quantity > 0); var thingsInfo = GetMarketingMaterials(); var thingsInOrder = positiveSelection.Join(thingsInfo, a => a.Id, b => b.Id, (a, b) => new MarketingProduct(b,b.Category,a.Quantity)); var cartHeader = GetOrderReady(thingsInOrder); var request = Utils.GetRequestInfo(Method.POST, "/api/Orders/Add"); var insertOrderResponse = _webClient.Execute<OrderResponse>(new JsonSerializer().Serialize(cartHeader), ApiUrls.API_KEY, ApiUrls.API_SECRET, request); var confirmation = new OrderConfirmation { OrderConfirmationNumber = insertOrderResponse.OrderId, Address = Utils.GetFormattedAddress(userLogged.Address1, userLogged.Address2, userLogged.City, userLogged.State, userLogged.ZipCode, "USA"), Email = userLogged.Email, Phone = userLogged.Phone, Name = userLogged.Name, }; var result = insertOrderResponse.OrderId > 0? Utils.Success:"There were problems trying to process your order. Try it again later, please."; return Json(new{ShippingInfo = confirmation, Result = result}); } catch (Exception exception) { return Json(new { Result = "There were problems trying to process your order. Try it again later, please." }); } }