Exemplo n.º 1
0
        private static void MuaHangNhanh(int id, IBanHangServices service)
        {
            var order = new DTO.ThongTinKhachHang();

            order.Id = id;


            Console.ForegroundColor = ConsoleColor.Green;

            var name = AppUtil.GetRandomName();

            Console.WriteLine("===== THONG TIN KHACH HANG ====");
            Console.WriteLine($"     Ten khach hang: {name}");
            order.TenKhachHang = name;

            var address = AppUtil.GetRandomAddress();

            Console.WriteLine($"     Dia chi giao hang: {address}");
            order.DiaChi = address;

            var phoneNumber = AppUtil.GetRandomPhoneNumber();

            Console.WriteLine($"     Dien thoai lien lac: {phoneNumber}");
            order.DienThoai = phoneNumber;

            order.TrangThai = Config.Server.Kafka.Helper.Status.Da_Thanh_Toan.ToString();
            order.NgayTao   = DateTime.Now;
            order.IsInit    = true;
            order.IsDeleted = false;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("===== SAN PHAM MUA ====");

            var sp          = new SanPhamMua();
            var productName = AppUtil.GetRandomProduct();

            Console.WriteLine($"     Ten San Pham: {productName}");
            sp.TenSanPham = productName;

            int sl = 3;
            var productQuantity = AppUtil.GetRandomNumber();

            Console.WriteLine($"     So luong: {productQuantity}");
            sp.SoLuong = productQuantity;

            order.SanPhams.Add(sp);

            service.Them_DonHang(order);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Mua hang thanh cong....");
            Console.WriteLine();
            Console.ResetColor();
        }
Exemplo n.º 2
0
        private static void MuaHang(int id, IBanHangServices service)
        {
            var order = new DTO.ThongTinKhachHang();

            order.Id = id;


            Console.ForegroundColor = ConsoleColor.Green;

            Console.WriteLine("===== THONG TIN KHACH HANG ====");
            Console.WriteLine("     Ten khach hang:");
            order.TenKhachHang = Console.ReadLine();

            Console.WriteLine("     Dia chi giao hang:");
            order.DiaChi = Console.ReadLine();

            Console.WriteLine("     Dien thoai lien lac:");
            order.DienThoai = Console.ReadLine();

            order.TrangThai = Config.Server.Kafka.Helper.Status.Da_Thanh_Toan.ToString();
            order.NgayTao   = DateTime.Now;
            order.IsInit    = true;
            order.IsDeleted = false;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("===== SAN PHAM MUA ====");
            int key = 0;

            do
            {
                var sp = new SanPhamMua();
                Console.WriteLine("     Ten San Pham: ");
                sp.TenSanPham = Console.ReadLine();

                int sl = 0;
                Console.WriteLine("     So luong: ");
                int.TryParse(Console.ReadLine(), out sl);
                sp.SoLuong = sl;

                order.SanPhams.Add(sp);

                Console.WriteLine("1: tiep tuc mua hang, 0: mua xong");
                int.TryParse(Console.ReadLine(), out key);
            }while (key > 0);

            service.Them_DonHang(order);

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Mua hang thanh cong....");
            Console.ResetColor();
        }