Пример #1
0
        public IActionResult GetById(long id)
        {
            var bank = BankUtilities.GetBanks().FirstOrDefault(b => b.Id == id);

            if (bank == null)
            {
                return(NotFound());
            }
            return(new ObjectResult(bank));
        }
Пример #2
0
        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());
        }
Пример #3
0
        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());
        }
Пример #4
0
        public IEnumerable <string> GetAll()
        {
            var banks = JsonConvert.SerializeObject(BankUtilities.GetBanks());

            return(new string[] { banks });
        }