示例#1
0
        public static async Task UpdateDistributorAddress()
        {
            try
            {
                using (IDistributorAddressBL distributorAddressBL = new DistributorAddressBL())
                {
                    //Read Sl.No
                    Write("Distributor Address #: ");
                    bool isNumberValid = int.TryParse(ReadLine(), out int serial);
                    if (isNumberValid)
                    {
                        serial--;
                        List <DistributorAddress> distributorsAddress = await distributorAddressBL.GetAllDistributorAddressesBL();

                        if (serial <= distributorsAddress.Count - 1)
                        {
                            //Read inputs
                            DistributorAddress distributorAddress = distributorsAddress[serial];
                            Write("AddressLine1: ");
                            distributorAddress.AddressLine1 = ReadLine();
                            Write("AddressLine2: ");
                            distributorAddress.AddressLine2 = ReadLine();
                            Write("City: ");
                            distributorAddress.City = ReadLine();
                            Write("State: ");
                            distributorAddress.State = ReadLine();
                            Write("Pincode: ");
                            distributorAddress.PinCode = ReadLine();

                            //Invoke UpdateDistributorAddressBL method to update
                            bool isUpdated = await distributorAddressBL.UpdateDistributorAddressBL(distributorAddress);

                            if (isUpdated)
                            {
                                WriteLine("Distributor Address Updated");
                            }
                        }
                        else
                        {
                            WriteLine($"Invalid Distributor #.\nPlease enter a number between 1 to {distributorsAddress.Count}");
                        }
                    }
                    else
                    {
                        WriteLine($"Invalid number.");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }
示例#2
0
 private static void UpdateDistributorAddress()
 {
     try
     {
         int updateDistributorAddressID;
         Console.WriteLine("Enter DistributorAddressID to Update Details:");
         updateDistributorAddressID = Convert.ToInt32(Console.ReadLine());
         DistributorAddress updatedDistributorAddress = DistributorAddressBL.SearchDistributorAddressBL(updateDistributorAddressID);
         if (updatedDistributorAddress != null)
         {
             Console.WriteLine("Update Address Line1 :");
             updatedDistributorAddress.DistributorAddressLine1 = Console.ReadLine();
             Console.WriteLine("Update Address Line2 :");
             updatedDistributorAddress.DistributorAddressLine2 = Console.ReadLine();
             Console.WriteLine("Update City :");
             updatedDistributorAddress.DistributorCity = Console.ReadLine();
             Console.WriteLine("Update State :");
             updatedDistributorAddress.DistributorState = Console.ReadLine();
             Console.WriteLine("Update Pincode :");
             updatedDistributorAddress.DistributorPincode = Console.ReadLine();
             bool distributorAddressUpdated = DistributorAddressBL.UpdateDistributorAddressBL(updatedDistributorAddress);
             if (distributorAddressUpdated)
             {
                 Console.WriteLine("Distributor Address Details Updated");
             }
             else
             {
                 Console.WriteLine("Distributor Address Details not Updated ");
             }
         }
         else
         {
             Console.WriteLine("No Distributor Address Details Available");
         }
     }
     catch (InventoryException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }