Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] AccountViewModel account)
        {
            if (ModelState.IsValid)
            {
                var accountModel = _mapper.Map <Account>(account);
                var result       = await _repo.AddAccountToUserAsync(accountModel, User.Identity.Name);

                if (result > 0)
                {
                    return(Created("", null));
                }
                else
                {
                    return(BadRequest("Save failed"));
                }
            }
            else
            {
                return(BadRequest(account));
            }
        }