Ejemplo n.º 1
0
        public async Task Delete(Delete.Request request, CancellationToken cancellationToken)
        {
            var ad = await _repository.FindByIdWithUserInclude(request.Id, cancellationToken);

            if (ad == null)
            {
                throw new AdNotFoundException(request.Id);
            }

            var user = await _userService.GetCurrent(cancellationToken);

            if (ad.Owner.Id != user.Id)
            {
                throw new NoRightsException("Нет прав для выполнения операции.");
            }

            ad.Status    = Domain.Ad.Statuses.Closed;
            ad.UpdatedAt = DateTime.UtcNow;
            await _repository.Save(ad, cancellationToken);
        }