Exemplo n.º 1
0
        public OrderModel(OrderSearchDTO order, List <CartDetailSearchDTO> cartDetails)
        {
            ID        = order.ID.ToString().PadLeft(10, '0');
            Firstname = order.Firstname;
            Lastname  = order.Lastname;
            Phone     = order.Phone;
            ProcedureHelper  procedureHelper = new ProcedureHelper();
            AdminDivQueryDTO provinceDTO     = procedureHelper.GetData <AdminDivQueryDTO>(
                "administrative_division_table_query", new AdminDivQueryRequest {
                ID = order.ProvinceID
            })
                                               .FirstOrDefault();

            Province = provinceDTO.Name;
            AdminDivQueryDTO districtDTO = procedureHelper.GetData <AdminDivQueryDTO>(
                "administrative_division_table_query", new AdminDivQueryRequest {
                ID = order.DistrictID
            })
                                           .FirstOrDefault();

            District = districtDTO.Name;
            AdminDivQueryDTO communeDTO = procedureHelper.GetData <AdminDivQueryDTO>(
                "administrative_division_table_query", new AdminDivQueryRequest {
                ID = order.CommuneID
            })
                                          .FirstOrDefault();

            Commune       = communeDTO.Name;
            Address       = order.Address;
            Note          = order.Note;
            Status        = new OrderStatusModel();
            Status.ID     = order.StatusID;
            Status.Status = order.Status;
            Cart          = new CartModel();
            Cart.Subtotal = order.Subtotal;
            Cart.Delivery = order.Delivery;
            Cart.Discount = order.Discount;
            Cart.Total    = order.Total;
            for (int i = 0; i < cartDetails.Count; i++)
            {
                CartModel.CartDetailModel cartDetail =
                    new CartModel.CartDetailModel(cartDetails[i]);
                Cart.CartDetails.Add(cartDetail);
            }
        }