public async Task <IActionResult> CreateBirthDocsAsync([FromBody] IEnumerable <BirthDocResourceIn> birthDocResources) { _logger.LogInformation("Received BirthDocResource list: {@BirthDocs}", birthDocResources); var birthDocs = _mapper.Map <IEnumerable <BirthDocResourceIn>, IEnumerable <BirthDoc> >(birthDocResources); var result = await _birthDocService.CreateBirthDocsAsync(birthDocs /*, birthDocResources.Select(a=>a.GenderCode), birthDocResources.Select(a=>a.RelationCode)*/, true); if (result.Any(a => !a.Success)) { return(BadRequest(result.First(a => !a.Success).Message)); } var savedBirthDocs = _mapper.Map <IEnumerable <BirthDoc>, IEnumerable <BirthDocResourceOut> >(result.Select(a => a.BirthDoc)); return(Ok(savedBirthDocs)); }
private async Task <bool> CreateBirthDocs(IReadOnlyCollection <BirthDoc> birthDocs) { var docs = await _birthDocService.CreateBirthDocsAsync(birthDocs); return(docs.All(a => a.Success) ? true : false);//If all docs are created successfully return true, else return false }