//Update public void UpdateAccount(Account updateAccount) { //time is to the nano second? should serve as a good primary key var result = chartofAccount.FirstOrDefault( e => e.AccountType == updateAccount.AccountType && e.AccountName == updateAccount.AccountName); int index = chartofAccount.IndexOf(result); chartofAccount[index] = updateAccount; }
public Response<Account> EditAccount(Account updatedAccount) { var response = new Response<Account>(); try { repo.UpdateAccount(updatedAccount); response.Success = true; response.Attachment = updatedAccount; response.Message = "Account edit was a success"; } catch (Exception ex) { response.Success = false; response.Attachment = updatedAccount; response.Message = "Account edit failed!" + ex.Message; } return response; }
//Add public Response<Account> AddAccount(Account newAccount) { var response = new Response<Account>(); try { repo.CreateAccount(newAccount); response.Attachment = newAccount; response.Message = "Add account success!"; response.Success = true; } catch (Exception ex) { response.Message = "Add account failure" + ex.Message; response.Attachment = newAccount; response.Success = false; } return response; }
//Create public void CreateAccount(Account newAccount) { chartofAccount.Add(newAccount); }