private async Task HandleCreate(ClassifiedAds.V1.Create cmd) { if (await _repository.Exists <ClassifiedAd>(cmd.Id.ToString())) { throw new InvalidOperationException($"Entity with id {cmd.Id} already exists"); } var classifiedAd = new ClassifiedAd(new ClassifiedAdId(cmd.Id), new UserId(cmd.OwnerId)); await _repository.Save(classifiedAd); }
public Task Handle(ClassifiedAds.V1.Create command) { var ad = ClassifiedAd.Create( command.Id, command.OwnerId, command.CreatedBy, command.CreatedAt); return(_store.Save(ad)); }
public Task Handle(ClassifiedAds.V1.Create command) => _store.Save(ClassifiedAd.Create( command.Id, command.OwnerId, command.CreatedBy));
public async Task Handle(ClassifiedAds.V1.Create command) => ClassifiedAd.Create( command.Id, command.OwnerId, command.CreatedBy);
public async Task <IActionResult> Post(ClassifiedAds.V1.Create request) { await _applicationService.Handle(request); return(Ok()); }
public Task <IActionResult> Add(ClassifiedAds.V1.Create request) => RequestHandler.HandleRequest(request, _service.Handle, Log);