Ejemplo n.º 1
0
        public async Task <IActionResult> AddAccount(CloudAccountModel account)
        {
            try
            {
                var user = await TryGetUser(User);

                account.CreatorUserId = user.Id;

                var newAccountId = await _dataAccess.AddAccount(account);

                var getLink = Url.Action("GetAccountById", new { accountId = newAccountId });
                return(Created(getLink, null));
            }
            catch (Exception e)
            {
                _logger.LogError(e, "AddAccount");
                if (_hostEnvironment.IsDevelopment())
                {
                    throw;
                }

                return(BadRequest(new { Error = e.Message }));
            }
        }