public DB_EventName(TilerUser tilerUser, TilerEvent tilerEvent, string name, string id) { _Name = name; _Id = id; this._Creator = tilerUser; this._Event = tilerEvent; }
public override Task <Tuple <CustomErrors, Dictionary <string, CalendarEvent> > > BundleChangeUpdate(string EventId, EventName NewName, DateTimeOffset newStart, DateTimeOffset newEnd, int newSplitCount, string notes, bool forceRecalculation = false, SubCalendarEvent triggerSubEvent = null) { Task <TilerEvent> pendingNameAndMisc = null; //dynamic pendingNameAndMisc = null; bool useSubEvent = triggerSubEvent != null && triggerSubEvent.NameId.isNot_NullEmptyOrWhiteSpace() && triggerSubEvent.DataBlobId.isNot_NullEmptyOrWhiteSpace(); if (useSubEvent) { if (this.myAccount.ScheduleLogControl.Database != null) { pendingNameAndMisc = Task <TilerEvent> .Run(async() => { SubCalendarEvent subRetValue = await this.myAccount.ScheduleLogControl.Database.SubEvents .Include(eachSubEvent => eachSubEvent.DataBlob_EventDB) .Include(eachSubEvent => eachSubEvent.Name) .Include(eachSubEvent => eachSubEvent.SentimentAnalysis_DB) .FirstAsync(eachSubEvent => eachSubEvent.Id == triggerSubEvent.Id).ConfigureAwait(false); TilerEvent tileRetValue = (TilerEvent)subRetValue; return(tileRetValue); }); } } else { var calEent = getCalendarEvent(EventId); if (calEent != null) { if (this.myAccount.ScheduleLogControl.Database != null) { pendingNameAndMisc = Task <TilerEvent> .Run(async() => { CalendarEvent calRetValue = await this.myAccount.ScheduleLogControl.Database.CalEvents .Include(eachSubEvent => eachSubEvent.DataBlob_EventDB) .Include(eachSubEvent => eachSubEvent.Name) .FirstAsync(eachSubEvent => eachSubEvent.Id == calEent.Id).ConfigureAwait(false); TilerEvent tileRetValue = (TilerEvent)calRetValue; return(tileRetValue); }); } } } var retValue = base.BundleChangeUpdate(EventId, NewName, newStart, newEnd, newSplitCount, notes, forceRecalculation, triggerSubEvent); TilerEvent tilerEvent = null; if (!useSubEvent) { tilerEvent = getCalendarEvent(EventId); } else { tilerEvent = triggerSubEvent; } if (pendingNameAndMisc != null) { pendingNameAndMisc.Wait(); var pendingNameAndMiscResult = pendingNameAndMisc.Result; EventName oldName = pendingNameAndMiscResult.getName; MiscData miscData = pendingNameAndMiscResult.Notes; SentimentAnalysis sentimentAnalysis = pendingNameAndMiscResult.SentimentAnalysis_DB; bool isNameChange = NewName.NameValue != oldName?.NameValue; if (isNameChange) { string emojiString = Task.Run(async() => await OpenAIService.Instance().getEmojis(NewName.NameValue)).GetAwaiter().GetResult(); if (sentimentAnalysis != null) { sentimentAnalysis.updateEmoji(emojiString); } else { sentimentAnalysis = new SentimentAnalysis(); tilerEvent.SentimentAnalysis_DB = sentimentAnalysis; sentimentAnalysis.updateEmoji(emojiString); } tilerEvent.updateEventName(NewName.NameValue); } var note = miscData; if (note != null) { note.UserNote = notes; } } return(retValue); }