Пример #1
0
        protected override async Task <EntityResult <SampleDto> > HandleRequest(InsertRequest request,
                                                                                CancellationToken cancellationToken)
        {
            if (!request.IsValid)
            {
                return(request.GetResult(request.Item));
            }

            // TODO: validate that the entity does not exist or implement idempotence

            int calc =
                await _sampleService.CalculateSampleAsync(request.Item.ToEntity());

            // calc must be != 0
            request.AddNotifications(calc.NotEmpty());

            if (!request.IsValid)
            {
                return(request.GetResult(request.Item));
            }

            await _sampleRepository.InsertAsync(request.Item.ToEntity());

            await _unitOfWork.SaveAsync();

            return(request.GetResult(request.Item));
        }