/// <summary> /// get the client list from txt by DataAccess layer /// </summary> /// <returns></returns> public List <Client> ReadInformation() { List <Client> listOfClient = new List <Client>(); listOfClient = ClientDataMangement.ReadClientDA(); return(listOfClient); }
/// <summary> /// update the client's information /// </summary> /// <param name="oldCli"></param> /// <param name="newCli"></param> /// public void UpdateInformation(Client oldCli, Client newCli) { //read the original txt List <Client> listOfOldClient = ClientDataMangement.ReadClientDA(); List <Client> listOfNewClient = new List <Client>(); //update the line foreach (Client aclient in listOfOldClient) { if (aclient.Equals(newCli)) { listOfNewClient.Add(newCli); } else { listOfNewClient.Add(aclient); } } //delete file ClientDataMangement.DeleteClientFile(); //save a new list foreach (Client newClient in listOfNewClient) { ClientDataMangement.WriteClientDA(newClient); } }
/// <summary> /// get the client 's information by client object /// </summary> /// <param name="cli"></param> /// <returns></returns> /// public Client GetClientInformation(Client cli) { //read the original txt List <Client> listOfClient = ClientDataMangement.ReadClientDA(); Client clientFound = new Client(); //add to found list foreach (Client aclient in listOfClient) { if (aclient.ClientId == cli.ClientId || aclient.ClientName == cli.ClientName) { clientFound = aclient; } } return(clientFound); }
/// <summary> /// search the client's information by client object /// </summary> /// <param name="cli"></param> /// <returns></returns> /// public List <Client> SearchInformation(Client cli) { //read the original txt List <Client> listOfClient = ClientDataMangement.ReadClientDA(); List <Client> listOfFound = new List <Client>(); //add to found list foreach (Client aclient in listOfClient) { if (aclient.ClientId == cli.ClientId || aclient.ClientName == cli.ClientName || aclient.ClientType == cli.ClientType || aclient.PhoneNumber == cli.PhoneNumber || aclient.Email == cli.Email) { listOfFound.Add(aclient); } } return(listOfFound); }
//implemtment the interface /// <summary> /// save to txt file by client object /// </summary> /// <param name="cli"></param> public void SaveInformation(Client cli) { //TO-DO:validate ClientDataMangement.WriteClientDA(cli); }