Beispiel #1
0
 private static void UpdateSupplierBL()
 {
     try
     {
         Supplier updateSupplier = null;
         Console.WriteLine("Enter SupplierID to Update Details:");
         updateSupplier.SupplierID = Console.ReadLine();
         Supplier updatedSupplier = SupplierBL.SearchSupplierBL(updateSupplier.SupplierID);
         if (updatedSupplier != null)
         {
             Console.WriteLine("Update Supplier Name :");
             updatedSupplier.SupplierName = Console.ReadLine();
             Console.WriteLine("Update MobileNumber :");
             updatedSupplier.SupplierMobile = Console.ReadLine();
             bool supplierUpdated = SupplierBL.UpdateSupplierBL(updatedSupplier);
             if (supplierUpdated)
             {
                 Console.WriteLine("Guest Details Updated");
             }
             else
             {
                 Console.WriteLine("Guest Details not Updated ");
             }
         }
         else
         {
             Console.WriteLine("No Guest Details Available");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Beispiel #2
0
 private static void UpdateSupplier()
 {
     try
     {
         int updateSupplierID;
         Console.WriteLine("Enter SupplierID to Update Details:");
         updateSupplierID = Convert.ToInt32(Console.ReadLine());
         Supplier updatedSupplier = SupplierBL.SearchSupplierBL(updateSupplierID);
         if (updatedSupplier != null)
         {
             Console.WriteLine("Update Supplier Name :");
             updatedSupplier.SupplierName = Console.ReadLine();
             Console.WriteLine("Update PhoneNumber :");
             updatedSupplier.SupplierPhone = Console.ReadLine();
             bool supplierUpdated = SupplierBL.UpdateSupplierBL(updatedSupplier);
             if (supplierUpdated)
             {
                 Console.WriteLine("Supplier Details Updated");
             }
             else
             {
                 Console.WriteLine("Supplier Details not Updated ");
             }
         }
         else
         {
             Console.WriteLine("No Supplier Details Available");
         }
     }
     catch (InventoryException ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
        /// <summary>
        /// Updates Supplier.
        /// </summary>
        /// <returns></returns>
        public static async Task UpdateSupplier()
        {
            try
            {
                using (ISupplierBL supplierBL = new SupplierBL())
                {
                    //Read Sl.No
                    Write("Supplier #: ");
                    bool isNumberValid = int.TryParse(ReadLine(), out int serial);
                    if (isNumberValid)
                    {
                        serial--;
                        List <Supplier> suppliers = await supplierBL.GetAllSuppliersBL();

                        if (serial <= suppliers.Count - 1)
                        {
                            //Read inputs
                            Supplier supplier = suppliers[serial];
                            Write("Name: ");
                            supplier.SupplierName = ReadLine();
                            Write("Mobile: ");
                            supplier.SupplierMobile = ReadLine();
                            Write("Email: ");
                            supplier.Email = ReadLine();

                            //Invoke UpdateSupplierBL method to update
                            bool isUpdated = await supplierBL.UpdateSupplierBL(supplier);

                            if (isUpdated)
                            {
                                WriteLine("Supplier Updated");
                            }
                        }
                        else
                        {
                            WriteLine($"Invalid Supplier #.\nPlease enter a number between 1 to {suppliers.Count}");
                        }
                    }
                    else
                    {
                        WriteLine($"Invalid number.");
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex);
                WriteLine(ex.Message);
            }
        }