private async Task <List <MeterBulkUploadResponseDto> > ProcessRequestMprns(ModelDbContext dbContext, Site associatedSite, MprnDto[] mprns) { var mprnResults = new List <MeterBulkUploadResponseDto>(); { foreach (var mprnDto in mprns) { var existing = await dbContext.RetrieveMprnByCore(mprnDto.MprnCore); var mprnId = existing?.Id ?? Guid.NewGuid(); string mprnState; if (existing != null) { await SoftUpdateMprnFields(dbContext, associatedSite, existing, mprnDto); await dbContext.Update(existing); mprnState = BulkUploadResponseStates.Updated; } else { var mprn = Mapper.Map <Mprn>(mprnDto); mprn.Id = mprnId; mprn.Site = associatedSite; await dbContext.Add(mprn); mprnState = BulkUploadResponseStates.Created; } mprnResults.Add(new MeterBulkUploadResponseDto { Core = mprnDto.MprnCore, Id = mprnId, State = mprnState }); } return(mprnResults); } }