Example #1
0
        public int CreateOrder(DonDatHang order)
        {
            RestRequest request = new RestRequest("Order", Method.POST);
            string data = Post(request, order);
            int result = (int)DeserializeObject(data, typeof(int));

            return result;
        }
Example #2
0
        public DonDatHang CreateOrder(DetailsPayment details, string username)
        {
            NguoiNhan receiver = details.Receiver;

            DonDatHang order = new DonDatHang();
            order.NguoiNhan = receiver;
            order.MaPTGH = details.MaPTGH;
            order.MaPTTT = details.MaPTTT;
            order.MaTK = username;
            order.NgayLap = DateTime.Now;
            order.DonGia = 0;
            order.MaTrangThai = "CGTT";

            var cartItems = GetCartItems();
            order.ChiTietDonHangs = new List<ChiTietDonHang>();
            double total = 0;
            foreach (var item in cartItems)
            {
                var detailsOrder = new ChiTietDonHang
                {
                    MaDDH = order.MaDDH,
                    MaSP = item.MaSP,
                    SoLuong = item.SoLuong,
                    Gia = item.SanPham.GiaBanHienHanh
                };
                total += item.SanPham.GiaBanHienHanh;
                order.ChiTietDonHangs.Add(detailsOrder);
            }
            order.DonGia = total;

            return order;
        }