Пример #1
0
        public IActionResult DeleteAccount(int Id)
        {
            try
            {
                if (!_IbankRepo.AccountExists(Id))
                {
                    return(NotFound());
                }

                var bankObj = _IbankRepo.GetAccount(Id);

                if (!_IbankRepo.DeleteAccount(bankObj))
                {
                    ModelState.AddModelError("", $"Something happened while Deleting the record {bankObj.AccountNumber}");
                    return(StatusCode(500, ModelState));
                }


                return(NoContent()); //204 status-code, With Delete we don't retun any obj
            }
            catch (Exception e)
            {
                throw new Exception("Delete Account Error :", e);
            }
        }