public async Task <ActionResult <AuthorizedKey> > PostAuthorizedKey(AuthorizedKeyDto dto)
        {
            var authorizedKey = new AuthorizedKey()
            {
                Name = dto.Name, AuthToken = dto.AuthToken
            };

            authorizedKey.Id = Guid.NewGuid();
            _context.JustFill(this, authorizedKey);
            if (authorizedKey.Tenant == null || authorizedKey.Customer == null)
            {
                return(NotFound(new ApiResult <AuthorizedKey>(ApiCode.NotFoundTenantOrCustomer, $"Not found Tenant or Customer ", authorizedKey)));
            }
            _context.AuthorizedKeys.Add(authorizedKey);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAuthorizedKey", new { id = authorizedKey.Id }, authorizedKey));
        }
Пример #2
0
        public async Task <ApiResult <AuthorizedKey> > PostAuthorizedKey(AuthorizedKeyDto dto)
        {
            var authorizedKey = new AuthorizedKey()
            {
                Name = dto.Name, AuthToken = dto.AuthToken
            };

            authorizedKey.Id = Guid.NewGuid();
            _context.JustFill(this, authorizedKey);
            if (authorizedKey.Tenant == null || authorizedKey.Customer == null)
            {
                return(new ApiResult <AuthorizedKey>(ApiCode.CantFindObject, "can't find this object", null));
            }
            _context.AuthorizedKeys.Add(authorizedKey);
            await _context.SaveChangesAsync();

            return(await GetAuthorizedKey(authorizedKey.Id));
        }