private async Task FindFieldPreFillValues(eFormCore.Core sdkCore) { await using MicrotingDbContext microtingDbContext = sdkCore.DbContextHelper.GetDbContext(); Language language = await microtingDbContext.Languages.SingleAsync(x => x.LanguageCode == "da"); List <FieldDto> fieldDtos = await sdkCore.Advanced_TemplateFieldReadAll(TemplateId, language); foreach (FieldDto fieldDto in fieldDtos) { string value = FindValue($"F{fieldDto.Id}#"); if (!string.IsNullOrEmpty(value)) { AppointmentPrefillFieldValue appointmentPrefillFieldValue = new AppointmentPrefillFieldValue() { FieldId = fieldDto.Id, FieldValue = value }; AppointmentPrefillFieldValues.Add(appointmentPrefillFieldValue); } } }
public static Appointment AppointmentsFind(AppointmentPnDbContext dbContext, string globalId) { // log.LogStandard(t.GetMethodName("SQLController"), "AppointmentsFind looking for one with globalId " + globalId); try { var match = dbContext.Appointments.SingleOrDefault(x => x.GlobalId == globalId); if (match != null) { bool color_rule = match.ColorRule == 0 ? true : false; Appointment appo = new Appointment() { GlobalId = match.GlobalId, Start = (DateTime)match.StartAt, Duration = (int)match.Duration, Subject = match.Subject, ProcessingState = match.ProcessingState, Body = match.Body, ColorRule = color_rule, Id = match.Id }; appo.Completed = match.Completed == 0 ? false : true; try { appo.TemplateId = (int)match.SdkeFormId; } catch { } foreach (Microting.AppointmentBase.Infrastructure.Data.Entities.AppointmentSite appointmentSite in match.AppointmentSites) { AppointmentSite obj = new AppointmentSite() { Id = appointmentSite.Id, MicrotingSiteUid = appointmentSite.MicrotingSiteUid, ProcessingState = appointmentSite.ProcessingState, SdkCaseId = appointmentSite.SdkCaseId }; appo.AppointmentSites.Add(obj); } foreach (Microting.AppointmentBase.Infrastructure.Data.Entities.AppointmentPrefillFieldValue pfv in match.AppointmentPrefillFieldValues) { AppointmentPrefillFieldValue appointmentPrefillFieldValue = new AppointmentPrefillFieldValue() { Id = pfv.Id, FieldId = pfv.FieldId, AppointmentId = (int)pfv.AppointmentId, FieldValue = pfv.FieldValue }; appo.AppointmentPrefillFieldValues.Add(appointmentPrefillFieldValue); } return(appo); } else { return(null); } } catch (Exception ex) { // log.LogException(t.GetMethodName("SQLController"), "failed", ex, false); return(null); } }