private async Task HandleCreate(Contracts.V1.Create cmd)
        {
            if (await _store.Exists <Domain.ClassifiedAd.ClassifiedAd, ClassifiedAdId>(
                    new ClassifiedAdId(cmd.Id)))
            {
                throw new InvalidOperationException($"Entity with id {cmd.Id} already exists");
            }

            var classifiedAd =
                new Domain.ClassifiedAd.ClassifiedAd(new ClassifiedAdId(cmd.Id), new UserId(cmd.OwnerId));
            await _store.Save <Domain.ClassifiedAd.ClassifiedAd, ClassifiedAdId>(classifiedAd);
        }
Esempio n. 2
0
        private async Task HandleCreate(Contracts.V1.Create cmd)
        {
            if (await _repository.Exists(new ClassifiedAdId(cmd.Id)))
            {
                throw new InvalidOperationException($"Entity with id {cmd.Id} already exists");
            }

            var classifiedAd = new Domain.ClassifiedAd.ClassifiedAd(new ClassifiedAdId(cmd.Id), new UserId(cmd.OwnerId));

            await _repository.Add(classifiedAd);

            await _unitOfWork.Commit();
        }
 public Task <IActionResult> Post(Contracts.V1.Create request)
 => RequestHandler.HandleRequest(request, _applicationService.Handle, Log);