public async Task <IActionResult> GetById([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var accounttype = await _accounttypeRepository.GetAsync(id);

            if (accounttype != null)
            {
                return(Ok(accounttype));
            }
            else
            {
                return(BadRequest());
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] Account value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var type = await _accounttypeRepository.GetAsync(value.AccountTypeId);

            if (type == null)
            {
                return(BadRequest(new { Message = "Select a Valid Account Type" }));
            }
            value.Number = await _sequenceRepository.GetCode(type.SequenceId);

            await _accountRepository.InsertAsync(value);

            return(Created($"account/{value.AccountId}", value));
        }