public IActionResult GetById(long id) { var accounts = JsonConvert.SerializeObject(CustomerUtilities.GetCustomerAccounts(id.ToString())); if (accounts == null) { return(NotFound()); } return(new ObjectResult(accounts)); }
public IActionResult GetByString(string iban) { var customer = CustomerUtilities.GetAccountTransactions(iban); if (customer == null) { return(NotFound()); } return(new ObjectResult(customer)); }
public IActionResult Create([FromBody] BankDB.Model.BankAccount account) { if (account == null) { return(BadRequest()); } CustomerUtilities.AddCustomerBankAccount(account.Iban, account.Name, account.BankId, account.CustomerId, account.Balance.ToString()); return(CreatedAtRoute("GetAccounts", new { id = account.CustomerId }, account)); }
public IActionResult Create([FromBody] BankDB.Model.Customer customer) { if (customer == null) { return(BadRequest()); } var newCustomer = CustomerUtilities.AddCustomer(customer.FirstName, customer.LastName, customer.BankId.ToString()); return(CreatedAtRoute("GetCustomer", new { id = newCustomer.Id }, customer)); }
public IActionResult Create([FromBody] BankDB.Model.BankAccountTransaction transaction) { if (transaction == null) { return(BadRequest()); } CustomerUtilities.AddCustomerTransaction(transaction.Iban, transaction.Amount.ToString()); return(CreatedAtRoute("GetTransactions", new { iban = transaction.Iban }, transaction)); }
public IActionResult Delete(long id) { var customer = BankUtilities.GetUsers().FirstOrDefault(c => c.Id == id); if (customer == null) { return(NotFound()); } CustomerUtilities.DeleteCustomer(customer.Id.ToString()); return(new NoContentResult()); }
public HttpResponseMessage Transactions(int customerId = 0, string email = "") { if (customerId != 0 || !string.IsNullOrEmpty(email)) { var customer = CustomerUtilities.GetCustomerByIdOrEmail(customerId, email); if (customer != null) { var model = CustomerUtilities.Model(customer); return(Request.CreateResponse(HttpStatusCode.OK, model)); } return(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Request.CreateResponse(HttpStatusCode.BadRequest)); }
public IActionResult Update(long id, [FromBody] BankDB.Model.Customer updatedCustomer) { if (updatedCustomer == null || updatedCustomer.Id != id) { return(BadRequest()); } var customer = BankUtilities.GetUsers().FirstOrDefault(c => c.Id == id); if (customer == null) { return(NotFound()); } customer.FirstName = updatedCustomer.FirstName; customer.LastName = updatedCustomer.LastName; CustomerUtilities.UpdateCustomerData(customer.Id.ToString(), customer.FirstName, customer.LastName); return(new NoContentResult()); }
public IActionResult Delete(string iban) { CustomerUtilities.DeleteCustomerAccount(iban); return(new NoContentResult()); }
private void TestCustomerTransactions_ShouldReturnCustomer() { var customer = CustomerUtilities.GetCustomerByIdOrEmail(email: "*****@*****.**"); Assert.AreEqual(true, customer.Transactions.Count() > 0); }
private void TestCustomerEmail_ShouldReturnCustomer() { var customer = CustomerUtilities.GetCustomerByIdOrEmail(email: "*****@*****.**"); Assert.AreEqual(true, customer != null); }
private void TestCustomerId_ShouldReturnCustomer() { var customer = CustomerUtilities.GetCustomerByIdOrEmail(435622); Assert.AreEqual(true, customer != null); }