public OrderDTO ToSimpleDto(Order o) { OrderDTO oDto = new OrderDTO { OrderID = o.OrderID, Address = o.Address, CustomerPhone = o.CustomerPhone, Date = o.Date, State = (new StateAssembler()).ToSimpleDto(o.State) }; oDto.OrderDetailsDTO = new List<OrderDetailDTO>(); foreach (var od in o.OrderDetails) { List<OrderIngredientDTO> oIngDtos = new List<OrderIngredientDTO>(); foreach (var ing in od.Ingredients) { oIngDtos.Add(new OrderIngredientDTO { IngredientID = ing.IngredientID, Name = ing.Ingredient.Name, Price = ing.Ingredient.PricePerUnit, Quantity = ing.Quantity, ExtraWeight = ing.Ingredient.ExtraWeight, NormalWeight = ing.Ingredient.NormalWeight }); } oDto.OrderDetailsDTO.Add(new OrderDetailDTO { OrderDetailID=od.OrderDetailID, Ingredients = oIngDtos, Size = new SizeDTO { SizeValue = od.Size.SizeValue } }); } return oDto; }
public OrdersRow(OrderDTO order) : this() { this.Order = order; }
public ActionResult AddToOrder(OrderInfoDTO info) { if (!((bool?)this.Session["LoggedIn"] ?? false)) return RedirectToAction("Login", "Account"); if (Request.IsAjaxRequest()) { try { using (var proxy = factory.GetWorkChannel()) { List<OrderIngredientDTO> ings = proxy.QueryIngredients(new QueryRequest<IngredientsQuery> { Query = new IngredientsQuery { Login = ((UserDTO)this.Session["User"]).Email, Password = ((UserDTO)this.Session["User"]).Password, IngredientIds = info.Ingredients } }).Data; for (int i = 0; i < ings.Count; i++) { ings[i].Quantity = (info.Quantities[i] == "normal") ? ings[i].NormalWeight : ings[i].ExtraWeight; } double sizeValue = GetSize(info); SizeDTO size = new SizeDTO { SizeValue = sizeValue }; List<OrderDetailDTO> od = new List<OrderDetailDTO> { new OrderDetailDTO { Ingredients=ings, Size=size } }; OrderDTO data = new OrderDTO { OrderDetailsDTO = od }; return PartialView("_OrderList", data); } } catch (Exception e) { return HandleFaults(e); } } return View(); }
public void MakeOrderTest() { PizzaService.PizzaService svc = new PizzaService.PizzaService(); InAutoRollbackTransaction(uow => { List<OrderIngredientDTO> ings = new List<OrderIngredientDTO>(); ings.Add( (new IngredientAssembler()).ToOrderIngredientDto(uow.Db.Ingredients.Get(1)) ); List<OrderDetailDTO> od = new List<OrderDetailDTO>(); od.Add(new OrderDetailDTO { Size = (new SizeAssembler()).ToSimpleDto(uow.Db.Sizes.Find(Size.MEDIUM)), Ingredients = ings }); OrderDTO order = new OrderDTO { Address = "A", CustomerPhone = 1, Date = new DateTime(1992, 6, 21), State = new StateDTO { StateValue = State.NEW }, OrderDetailsDTO = od }; svc.MakeOrder(new UpdateRequest<OrderDTO> { Login = customer.Email, Password = customer.Password, Data = order }); List<OrderDTO> orders = svc.GetUndoneOrders(new EmptyRequest { Login = emp.Email, Password = emp.Password }).Data; OrderDTO inserted = null; for (int i = 0; i < orders.Count; i++) { if (orders[i].Address == "A") { inserted = orders[i]; break; } } Assert.IsNotNull(inserted); Assert.IsTrue(order.CustomerPhone == inserted.CustomerPhone); Assert.IsTrue(order.Date == inserted.Date); Assert.IsTrue(order.State.StateValue == inserted.State.StateValue); for (int i = 0; i < order.OrderDetailsDTO.Count; i++) { Assert.IsTrue(order.OrderDetailsDTO[i].Size.SizeValue == inserted.OrderDetailsDTO[i].Size.SizeValue); for (int j = 0; j < order.OrderDetailsDTO[i].Ingredients.Count; j++) { Assert.IsTrue(order.OrderDetailsDTO[i].Ingredients[j].ExtraWeight == inserted.OrderDetailsDTO[i].Ingredients[j].ExtraWeight); Assert.IsTrue(order.OrderDetailsDTO[i].Ingredients[j].Name == inserted.OrderDetailsDTO[i].Ingredients[j].Name); Assert.IsTrue(order.OrderDetailsDTO[i].Ingredients[j].NormalWeight == inserted.OrderDetailsDTO[i].Ingredients[j].NormalWeight); Assert.IsTrue(order.OrderDetailsDTO[i].Ingredients[j].Price == inserted.OrderDetailsDTO[i].Ingredients[j].Price); Assert.IsTrue(order.OrderDetailsDTO[i].Ingredients[j].Quantity == inserted.OrderDetailsDTO[i].Ingredients[j].Quantity); } } }); }
public void UpdateEntity(Order order, OrderDTO orderDTO) { order.StateID = orderDTO.State.StateID; }