public static void AddCustomer() { Customer customer = new Customer(); Console.Write("Enter customer name: "); customer.CustomerName = Console.ReadLine(); ICustomerBusinessLogicLayer customerBusinessLogicLayer = new CustomerBusinessLogicLayer(); customerBusinessLogicLayer.AddCustomer(customer); //call BL Console.WriteLine(customer.GetType()); //Output: Znalytics.OnlineShopping.CustomersModule.Entities.Customer Console.WriteLine(customer.ToString()); //Output: Znalytics.OnlineShopping.CustomersModule.Entities.Customer Console.WriteLine(customer.GetHashCode()); //Output: 46104728 Customer customer1 = new Customer() { CustomerName = "John", Email = "*****@*****.**" }; Customer customer2 = new Customer() { CustomerName = "John", Email = "*****@*****.**" }; Console.WriteLine(customer1.Equals(customer2)); //Output: True }
static void Main(string[] args) { CustomerBusinessLogicLayer customerBusinessLogicLayer = new CustomerBusinessLogicLayer(); customerBusinessLogicLayer.DeleteCustomer(); Console.ReadKey(); }
/// <summary> /// Static Method to add Customer Details /// </summary> static void AddCustomer() { try { //Creating object for Entity layer that is CustomerDetail class Customer customer = new Customer(); //Creating object for BusinessLogic Layer CustomerBusinessLogicLayer cb = new CustomerBusinessLogicLayer(); //Reading customer name manually Console.Write("Enter customer name: "); customer.CustomerName = Console.ReadLine(); //Reading customer Id manually //Console.Write("Enter customer Id: "); //customer.CustomerId = int.Parse(Console.ReadLine()); //Reading Occupation of customer manually Console.Write("Enter Profession: "); customer.Profession = Console.ReadLine(); //Reading Address of custometr manually Console.Write("Enter customer Address: "); customer.Address = Console.ReadLine(); //Reading Customer Income manually Console.Write("Enter customer Income: "); customer.AnnualIncome = double.Parse(Console.ReadLine()); //Reading customer's Pancard number manually Console.Write("Enter customer Pancardnumber(Pancardnumber should starts with 5alphabets followed by 4digits and then 1alphabet(eg:asdfg1234g)): "); customer.PanCardNumber = Console.ReadLine(); //Reading Customer's aadharcardnumber manually Console.Write("Enter customer Aadharcardnumber that must be 12 digits: "); customer.AadharCardNumber = Console.ReadLine(); //Reading Phone number of customer manually Console.Write("Enter customer Phone number that must be 10 digits: "); customer.PhoneNumber = Console.ReadLine(); //Reading Customer's age manually Console.Write("Enter Age "); customer.Age = int.Parse(Console.ReadLine()); //Reading customer's mail id manually Console.Write("Enter customer MailId(eg:[email protected]): "); customer.MailId = Console.ReadLine(); cb.AddCustomer(customer); //calling the AddCustomer method present in businessLogicLayer by using Reference variable Console.WriteLine("Customer details are added successfully"); } catch (CustomerException ex) { throw new CustomerException(ex.Message); } }
/// <summary> /// Method to get details by customer Id /// </summary> static void GetCustomersByCustomerId() { System.Console.Write("Enter the customerID: "); int CustomerId = int.Parse(System.Console.ReadLine()); CustomerBusinessLogicLayer cbl = new CustomerBusinessLogicLayer(); //Creating object to BusinessLogic layer of customer Customer b = cbl.GetCustomersByCustomerId(CustomerId); ///which calls the businesslogic of GetCustomersByCustomerId method/// System.Console.WriteLine(b.CustomerId + " " + b.CustomerName + " " + b.Address + " " + b.PanCardNumber + " " + b.AadharCardNumber + " " + b.Profession + " " + b.PhoneNumber + " " + b.AnnualIncome); }
/// <summary> /// Method to View existing Customer details /// </summary> static void GetCustomers() { CustomerBusinessLogicLayer cbl = new CustomerBusinessLogicLayer(); List <Customer> customers = cbl.GetCustomers();//getting all the customers stored in list Console.WriteLine("=============== customer Details============="); Console.WriteLine("CustomerID" + " " + "CustomerName" + " " + "MailId" + " " + "Phonenumber" + " " + "address" + " " + "AnnualIncome" + " " + "aadharcardnumber" + " " + "Pancardnumber"); Console.WriteLine("-----------------------------------------------------------------------"); foreach (Customer item in customers) //retrieves the data { Console.WriteLine(item.CustomerId + " " + item.CustomerName + " " + item.MailId + " " + item.AadharCardNumber + " " + item.Address + " " + item.AnnualIncome + " " + item.PanCardNumber + " " + item.Age + " " + item.Address + " " + item.AnnualIncome + " " + item.PanCardNumber + " " + item.Profession + " " + item.Address); // Displaying the products } }
/// <summary> /// Method to Update customer details /// </summary> static void UpdateCustomer() { //Creating object for CustomerPersonalDetail class Customer customer = new Customer(); //Creating object for BusinessLogic Layer CustomerBusinessLogicLayer cb = new CustomerBusinessLogicLayer(); Console.Write("Enter Existing customer ID: ");/// updating name and other details by using customerid/// customer.CustomerId = int.Parse(Console.ReadLine()); Console.Write("enter customer name: "); customer.CustomerName = Console.ReadLine(); cb.UpdateCustomer(customer);//Calls BusinessLogic Layer Console.WriteLine("Customer details Updated successfully"); }
public static void DeleteCustomer(this CustomerBusinessLogicLayer cbll) { //cbll.AddCustomer(); Console.WriteLine("DeleteCustomer extension method"); }