/// <summary> /// Delete Address. /// </summary> /// <returns></returns> public static async Task DeleteAddress() { try { using (IAddressBL addressBL = new AddressBL()) { //Read Sl.No Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; RetailerBL retailerBL = new RetailerBL(); Retailer retailer = await retailerBL.GetRetailerByEmailBL(CommonData.CurrentUser.Email); List<Address> addresses = await addressBL.GetAddressByRetailerIDBL(retailer.RetailerID); Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { if (serial <= addresses.Count - 1) { //Invoke DeleteSystemUserBL method to delete Address address = addresses[serial]; bool isDeleted = await addressBL.DeleteAddressBL(address.AddressID); if (isDeleted) { WriteLine("Retailer Address Deleted"); } } } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public static async Task DeleteAddress() { try { using (IAddressBL addressBL = new AddressBL()) { Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int number); if (isNumberValid) { number--; CustomerBL customerBL = new CustomerBL(); Customer customer = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email); List <Address> addresses = await addressBL.GetAddressByCustomerIDBL(customer.CustomerID); Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { if (number <= addresses.Count - 1) { Address address = addresses[number]; bool isDeleted = await addressBL.DeleteAddressBL(address.AddressID); if (isDeleted) { WriteLine("Customer Address Deleted"); } } } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }