/// <summary> /// Adds Distributor. /// </summary> /// <returns></returns> public static async Task AddDistributor() { try { //Read inputs Distributor distributor = new Distributor(); Write("Name: "); distributor.DistributorName = ReadLine(); Write("Mobile: "); distributor.DistributorMobile = ReadLine(); Write("Email: "); distributor.Email = ReadLine(); Write("Password: "******"Distributor Added"); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
private static void AddDistributor() { try { Distributor distributor = new Distributor(); Console.WriteLine("Enter Distributor ID :"); distributor.DistributorID = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Distributor Name :"); distributor.DistributorName = Console.ReadLine(); Console.WriteLine("Enter PhoneNumber :"); distributor.DistributorContactNumber = Console.ReadLine(); Console.WriteLine("Enter Email ID :"); distributor.DistributorEmail = Console.ReadLine(); bool distributorAdded = DistributorBL.AddDistributorBL(distributor); if (distributorAdded) { Console.WriteLine("Distributor Added"); } else { Console.WriteLine("Distributor not Added"); } } catch (InventoryException ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Displays list of Distributors. /// </summary> /// <returns></returns> public static async Task ViewDistributors() { try { using (IDistributorBL distributorBL = new DistributorBL()) { //Get and display list of system users. List <Distributor> distributors = await distributorBL.GetAllDistributorsBL(); WriteLine("DISTRIBUTORS:"); if (distributors != null && distributors?.Count > 0) { WriteLine("#\tName\tMobile\tEmail\tCreated\tModified"); int serial = 0; foreach (var distributor in distributors) { serial++; WriteLine($"{serial}\t{distributor.DistributorName}\t{distributor.DistributorMobile}\t{distributor.Email}\t{distributor.CreationDateTime}\t{distributor.LastModifiedDateTime}"); } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
private static void ListAllDistributors() { try { List <Distributor> distributorList = DistributorBL.GetAllDistributorsBL(); if (distributorList != null) { Console.WriteLine("******************************************************************************"); Console.WriteLine("Distributor ID\t\tDistributor Name\t\tPhoneNumber"); Console.WriteLine("******************************************************************************"); foreach (Distributor distributor in distributorList) { Console.WriteLine("{0}\t\t{1}\t\t{2}", distributor.DistributorID, distributor.DistributorName, distributor.DistributorContactNumber); } Console.WriteLine("******************************************************************************"); } else { Console.WriteLine("No Guest Details Available"); } } catch (InventoryException ex) { Console.WriteLine(ex.Message); } }
private static void SearchDistributorByID() { try { int searchDistributorID; Console.WriteLine("Enter Distributor ID to Search:"); searchDistributorID = Convert.ToInt32(Console.ReadLine()); Distributor searchDistributor = DistributorBL.SearchDistributorBL(searchDistributorID); if (searchDistributor != null) { Console.WriteLine("******************************************************************************"); Console.WriteLine("DistributorID\t\tDistributor Name\t\tPhoneNumber"); Console.WriteLine("******************************************************************************"); Console.WriteLine("{0}\t\t{1}\t\t{2}", searchDistributor.DistributorID, searchDistributor.DistributorName, searchDistributor.DistributorContactNumber); Console.WriteLine("******************************************************************************"); } else { Console.WriteLine("No Distributor Details Available"); } } catch (InventoryException ex) { Console.WriteLine(ex.Message); } }
private static void UpdateDistributor() { try { int updateDistributorID; Console.WriteLine("Enter DistributorID to Update Details:"); updateDistributorID = Convert.ToInt32(Console.ReadLine()); Distributor updatedDistributor = DistributorBL.SearchDistributorBL(updateDistributorID); if (updatedDistributor != null) { Console.WriteLine("Update Distributor Name :"); updatedDistributor.DistributorName = Console.ReadLine(); Console.WriteLine("Update PhoneNumber :"); updatedDistributor.DistributorContactNumber = Console.ReadLine(); bool distributorUpdated = DistributorBL.UpdateDistributorBL(updatedDistributor); if (distributorUpdated) { Console.WriteLine("Distributor Details Updated"); } else { Console.WriteLine("Distributor Details not Updated "); } } else { Console.WriteLine("No Distributor Details Available"); } } catch (InventoryException ex) { Console.WriteLine(ex.Message); } }
private static void DeleteDistributor() { try { int deleteDistributorID; Console.WriteLine("Enter DistributorID to Delete:"); deleteDistributorID = Convert.ToInt32(Console.ReadLine()); Distributor deleteDistributor = DistributorBL.SearchDistributorBL(deleteDistributorID); if (deleteDistributor != null) { bool distributordeleted = DistributorBL.DeleteDistributorBL(deleteDistributorID); if (distributordeleted) { Console.WriteLine("Distributor Deleted"); } else { Console.WriteLine("Distributor not Deleted "); } } else { Console.WriteLine("No Distributor Details Available"); } } catch (InventoryException ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Login (based on Email and Password) /// </summary> /// <returns></returns> static async Task <(UserType, IUser)> ShowLoginScreen() { //Read inputs string email, password; WriteLine("=====LOGIN========="); Write("Email: "); email = ReadLine(); Write("Password: "******"Invalid Email or Password. Please try again..."); return(UserType.Anonymous, null); }
/// <summary> /// Updates Distributor. /// </summary> /// <returns></returns> public static async Task UpdateDistributor() { try { using (IDistributorBL distributorBL = new DistributorBL()) { //Read Sl.No Write("Distributor #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; List <Distributor> distributors = await distributorBL.GetAllDistributorsBL(); if (serial <= distributors.Count - 1) { //Read inputs Distributor distributor = distributors[serial]; Write("Name: "); distributor.DistributorName = ReadLine(); Write("Mobile: "); distributor.DistributorMobile = ReadLine(); Write("Email: "); distributor.Email = ReadLine(); //Invoke UpdateDistributorBL method to update bool isUpdated = await distributorBL.UpdateDistributorBL(distributor); if (isUpdated) { WriteLine("Distributor Updated"); } } else { WriteLine($"Invalid Distributor #.\nPlease enter a number between 1 to {distributors.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
/// <summary> /// Delete Distributor. /// </summary> /// <returns></returns> public static async Task DeleteDistributor() { try { using (IDistributorBL distributorBL = new DistributorBL()) { //Read Sl.No Write("Distributor #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; List <Distributor> distributors = await distributorBL.GetAllDistributorsBL(); if (serial <= distributors.Count - 1) { //Confirmation Distributor distributor = distributors[serial]; Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { //Invoke DeleteDistributorBL method to delete bool isDeleted = await distributorBL.DeleteDistributorBL(distributor.DistributorID); if (isDeleted) { WriteLine("Distributor Deleted"); } } } else { WriteLine($"Invalid Distributor #.\nPlease enter a number between 1 to {distributors.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }