Пример #1
0
        internal MDLabReport GetDBLabReport(LabReport report)
        {
            MDLabReport mdReport = report.ConvertToDbEntity();

            mdReport.InsertedDate = DateTime.Now;
            mdReport.UpdatedDate  = DateTime.Now;
            mdReport.isDeleted    = false;
            return(mdReport);
        }
Пример #2
0
 public static LabReport ConvertToDomain(this MDLabReport report)
 {
     return(new LabReport()
     {
         ProfileId = report.ProfileID,
         ReportId = report.LabReportId,
         ReportName = string.Empty,
         ReportDate = report.ReportDate,
         LabTests = JsonConvert.DeserializeObject <List <LabTest> >(report.Report)
     });
 }
Пример #3
0
        public async Task <long> UpsertReportAsync(LabReport report)
        {
            MDLabReport dbLabReport = await dbContext.LabReports.Where(rpt => rpt.LabReportId == report.ReportId).FirstOrDefaultAsync();

            if (dbLabReport == null)
            {
                dbLabReport = GetDBLabReport(report);
                dbContext.MemberProfiles.Where(mp => mp.ProfileID == dbLabReport.ProfileID).FirstOrDefault().ConsolidatedReport = dbLabReport.Report;
                dbContext.LabReports.Add(dbLabReport);
            }
            else
            {
                dbLabReport.Report = JsonConvert.SerializeObject(report.LabTests);
                dbLabReport.MemberProfile.ConsolidatedReport = dbLabReport.Report;
            }

            await dbContext.SaveChangesAsync();

            return(dbLabReport.LabReportId);
        }