예제 #1
0
        public static void CreateExpressWaybill()
        {
            var cargo           = (NpCargo)NpFactory.GetInstance().CreateCargo();
            var sender          = (NpSender)NpFactory.GetInstance().CreateSender();
            var receiver        = (NpReceiver)NpFactory.GetInstance().CreateReceiver();
            var deliveryAddress = (NpDeliveryAddress)NpFactory.GetInstance().CreateDeliveryAddress();
            var senderAddress   = (NpSenderAddress)NpFactory.GetInstance().CreateSenderAddress();
            var options         = (NpOptions)NpFactory.GetInstance().CreateOptions();

            Console.WriteLine("Введіть дані відправника");
            Console.WriteLine(" ID контрагента:");
            sender.CounterpartyId = Console.ReadLine();
            Console.WriteLine(" ID відправника:");
            sender.Id = Console.ReadLine();
            Console.WriteLine(" Номер моб.телефону:");
            sender.Phone = Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Введіть адресу відправника");
            Console.WriteLine(" ID міста:");
            senderAddress.CityId = Console.ReadLine();
            Console.WriteLine(" ID відділення:");
            senderAddress.DepartmentId = Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Введіть дані отримувача");
            Console.WriteLine(" Прізвище:");
            receiver.LastName = Console.ReadLine();
            Console.WriteLine(" Ім'я:");
            receiver.FirstName = Console.ReadLine();
            Console.WriteLine(" По-батькові:");
            receiver.MiddleName = Console.ReadLine();
            Console.WriteLine(" Номер моб.телефону:");
            receiver.Phone = Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Введіть адресу отримувача");
            Console.WriteLine(" Область:");
            deliveryAddress.Region = Console.ReadLine();
            Console.WriteLine(" Місто:");
            deliveryAddress.City = Console.ReadLine();
            Console.WriteLine(" Район:");
            deliveryAddress.District = Console.ReadLine();
            Console.WriteLine(" Вулиця:");
            deliveryAddress.Street = Console.ReadLine();
            Console.WriteLine(" Номер будинку:");
            deliveryAddress.House = Console.ReadLine();
            Console.WriteLine(" Номер поверху або квартири:");
            deliveryAddress.Flat = Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Введіть параметри вантажу");
            Console.WriteLine(" Вага:");
            cargo.Weight = float.Parse(Console.ReadLine() ?? string.Empty);
            Console.WriteLine(" Висота:");
            cargo.Height = float.Parse(Console.ReadLine() ?? string.Empty);
            Console.WriteLine(" Ширина:");
            cargo.Width = float.Parse(Console.ReadLine() ?? string.Empty);
            Console.WriteLine(" Глибина:");
            cargo.Length = float.Parse(Console.ReadLine() ?? string.Empty);
            Console.WriteLine(" Тип вантажу:");
            options.CargoType = Console.ReadLine();
            Console.Clear();

            Console.WriteLine("Введіть додаткові параметри відправлення");
            Console.WriteLine(" Тип доставки:");
            options.DeliveryType = Console.ReadLine();
            Console.WriteLine(" Спосіб оплати:");
            options.PaymentMethod = Console.ReadLine();
            Console.WriteLine(" Опис:");
            options.Description = Console.ReadLine();
            Console.WriteLine(" Вартість:");
            options.CargoCost = float.Parse(Console.ReadLine() ?? string.Empty);
            Console.Clear();

            var expressWaybill = (NpExpressWaybillBuilder)NpExpressWaybillBuilder.GetInstance()
                                 .AddSender(sender)
                                 .AddReceiver(receiver)
                                 .AddSenderAddress(senderAddress)
                                 .AddDeliveryAddress(deliveryAddress)
                                 .AddCargo(cargo)
                                 .AddOptions(options);

            Console.Write(expressWaybill.GetResult());
        }
 public static NpExpressWaybillBuilder GetInstance()
 {
     return(_instance ?? (_instance = new NpExpressWaybillBuilder()));
 }