예제 #1
0
        public async Task <IActionResult> CreateDivorceDocsAsync([FromBody] IEnumerable <DivorceDocResourceIn> divorceDocsResource)
        {
            _logger.LogInformation("Received DivorceDocResource list: {@DivorceDoc}", divorceDocsResource);
            var divorceDocs = _mapper.Map <IEnumerable <DivorceDocResourceIn>, IEnumerable <DivorceDoc> >(divorceDocsResource);

            var result = await _divorceDocService.CreateDivorceDocsAsync(divorceDocs, true);

            if (result.Any(a => !a.Success))
            {
                return(BadRequest(result.First(a => !a.Success).Message));
            }

            var savedDivorceDocs = _mapper.Map <IEnumerable <DivorceDoc>, IEnumerable <DivorceDocResourceOut> >(result.Select(a => a.DivorceDoc));

            return(Ok(savedDivorceDocs));
        }
예제 #2
0
        private async Task <bool> CreateDivorceDocs(IReadOnlyCollection <DivorceDoc> divorceDocs)
        {
            var docs = await _divorceDocService.CreateDivorceDocsAsync(divorceDocs);

            return(docs.All(a => a.Success) ? true : false);//If all docs are created successfully return true, else return false
        }