예제 #1
0
        public async Task <int> DeactivateListing(int id)
        {
            try
            {
                if (id < 1 || id > 1000000)
                {
                    throw new ValidationException(nameof(id));
                }

                if (!(await _authorizationService.AuthorizeAsync(User, new Listing {
                    Id = id
                }, Operations.Delete)).Succeeded)
                {
                    throw new UnauthorizedAccessException();
                }

                return(await _listingService.DeActivateListing(id));
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message, e);
                throw;
            }
        }