public IActionResult GetById(long id) { var bank = BankUtilities.GetBanks().FirstOrDefault(b => b.Id == id); if (bank == null) { return(NotFound()); } return(new ObjectResult(bank)); }
public IActionResult Delete(long id) { var bank = BankUtilities.GetBanks().FirstOrDefault(b => b.Id == id); if (bank == null) { return(NotFound()); } BankUtilities.DeleteBank(bank.Id); return(new NoContentResult()); }
public IActionResult Update(long id, [FromBody] BankDB.Model.Bank updatedBank) { if (updatedBank == null || updatedBank.Id != id) { return(BadRequest()); } var bank = BankUtilities.GetBanks().FirstOrDefault(b => b.Id == id); if (bank == null) { return(NotFound()); } bank.Name = updatedBank.Name; bank.Bic = updatedBank.Bic; BankUtilities.UpdateBank(bank.Id, bank.Name, bank.Bic); return(new NoContentResult()); }
public IEnumerable <string> GetAll() { var banks = JsonConvert.SerializeObject(BankUtilities.GetBanks()); return(new string[] { banks }); }