public async Task <IActionResult> RemoveAppointment([FromBody] AInfo info) { try { var appointment = await _dbContext.Appointments.AsNoTracking().Include(a => a.Doctor).Include(a => a.Info).SingleOrDefaultAsync(a => a.Id == info.id); if (appointment == null) { return(Ok("Fail")); } appointment.RowVersion = info.rowVersion; _dbContext.Appointments.Remove(appointment); _dbContext.SaveChanges(); if (appointment.Status == "Confirmed") { var eventId = appointment.EventId; var request = _calendar.Service.Events.Delete(_calendar.CalendarId, eventId); await request.ExecuteAsync(); } } catch (DbUpdateConcurrencyException) { return(Ok("Fail")); } return(Ok("Removed")); }
private AInfo DataRowToEntity(DataRow row) { AInfo info = new AInfo(); info.ID = Convert.ToInt32(row["ID"]); info.Value = Convert.ToInt32(row["Value"]); return(info); }
public AInfo FindByID(object id) { AInfo result = null; string sql = @"SELECT ID,Value FROM A WHERE ID=@id"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("id", id), }; DataTable table = SqlHelper.ExecuteDataset(sql, param).Tables[0]; if (table != null && table.Rows.Count > 0) { result = DataRowToEntity(table.Rows[0]); } return(result); }
public int Insert(AInfo model, SqlTransaction trans = null) { string sql = @"INSERT INTO A (ID,Value) VALUES (@ID,@Value)"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("ID", model.ID), new SqlParameter("Value", model.Value), }; if (trans == null) { SqlHelper.ExecuteScalar(sql, param); } else { SqlHelper.ExecuteScalar(trans, sql, param); } return(model.ID); }
public int Update(AInfo model, SqlTransaction trans = null) { string sql = @"UPDATE A SET Value=@Value WHERE ID=@ID"; SqlParameter[] param = new SqlParameter[] { new SqlParameter("ID", model.ID), new SqlParameter("Value", model.Value), }; if (trans == null) { return(SqlHelper.ExecuteNonQuery(sql, param)); } else { return(SqlHelper.ExecuteNonQuery(trans, sql, param)); } }
public async Task <IActionResult> RemoveFreeTime([FromBody] AInfo info) { try { var freeTime = await _dbContext.FreeTimes.AsNoTracking().Include(a => a.Doctor).SingleOrDefaultAsync(ft => ft.Id == info.id); if (freeTime == null) { return(Ok("Fail")); } //var appointments = _dbContext.Appointments.AsNoTracking().Include(a => a.Doctor) // .Where(a => a.Status == "Confirmed" && a.Doctor.Name == freeTime.Doctor.Name && a.Start.Date == freeTime.Start.Date); //var intersectedAppointments = new List<Appointment>(); //foreach (var a in appointments) //{ // if (!(a.End <= freeTime.Start || a.Start >= freeTime.End)) // a and freeTime intersect in time // { // intersectedAppointments.Add(a); // } //} freeTime.RowVersion = info.rowVersion; _dbContext.FreeTimes.Remove(freeTime); _dbContext.SaveChanges(); } catch (DbUpdateConcurrencyException) { return(Ok("Fail")); } return(Ok("Removed")); }
private void SetGizmoState(AInfo ainfo) { AnnotationUtility.SetGizmoEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, (!ainfo.m_GizmoEnabled) ? 0 : 1); SceneView.RepaintAll(); }
private void DrawListElement(Rect rect, bool even, AInfo ainfo) { if (ainfo == null) { Debug.LogError("DrawListElement: AInfo not valid!"); return; } float num = 17f; float a = 0.3f; bool changed = GUI.changed; bool enabled = GUI.enabled; Color color = GUI.color; GUI.changed = false; GUI.enabled = true; GUIStyle style = (!even) ? AnnotationWindow.m_Styles.listOddBg : AnnotationWindow.m_Styles.listEvenBg; GUI.Label(rect, GUIContent.Temp(string.Empty), style); Rect position = rect; position.width = rect.width - 64f - 22f; GUI.Label(position, ainfo.m_DisplayText, AnnotationWindow.m_Styles.listTextStyle); float num2 = 16f; Rect rect2 = new Rect(rect.width - 64f, rect.y + (rect.height - num2) * 0.5f, num2, num2); Texture texture = null; if (ainfo.m_ScriptClass != string.Empty) { texture = EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass)); Rect position2 = rect2; position2.x += 18f; position2.y += 1f; position2.width = 1f; position2.height = 12f; if (!EditorGUIUtility.isProSkin) { GUI.color = new Color(0f, 0f, 0f, 0.33f); } else { GUI.color = new Color(1f, 1f, 1f, 0.13f); } GUI.DrawTexture(position2, EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill); GUI.color = Color.white; Rect rect3 = rect2; rect3.x += 18f; rect3.y = rect3.y; rect3.width = 9f; if (GUI.Button(rect3, this.iconSelectContent, AnnotationWindow.m_Styles.iconDropDown)) { UnityEngine.Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass); if (script != null) { this.m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass; if (IconSelector.ShowAtPosition(script, rect3, true)) { IconSelector.SetMonoScriptIconChangedCallback(new IconSelector.MonoScriptIconChangedCallback(this.MonoScriptIconChanged)); GUIUtility.ExitGUI(); } } } } else { if (ainfo.HasIcon()) { texture = AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID); } } if (texture != null) { if (!ainfo.m_IconEnabled) { GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, a); string tooltip = string.Empty; } this.iconToggleContent.image = texture; if (GUI.Button(rect2, this.iconToggleContent, GUIStyle.none)) { ainfo.m_IconEnabled = !ainfo.m_IconEnabled; this.SetIconState(ainfo); } GUI.color = color; } if (GUI.changed) { this.SetIconState(ainfo); GUI.changed = false; } GUI.enabled = true; GUI.color = color; if (ainfo.HasGizmo()) { string tooltip = "Show/Hide Gizmo"; Rect position3 = new Rect(rect.width - 23f, rect.y + (rect.height - num) * 0.5f, num, num); ainfo.m_GizmoEnabled = GUI.Toggle(position3, ainfo.m_GizmoEnabled, new GUIContent(string.Empty, tooltip), AnnotationWindow.m_Styles.toggle); if (GUI.changed) { this.SetGizmoState(ainfo); } } GUI.enabled = enabled; GUI.changed = changed; GUI.color = color; }
private void SyncToState() { Annotation[] annotations = AnnotationUtility.GetAnnotations(); string text = string.Empty; if (AnnotationWindow.s_Debug) { text += "AnnotationWindow: SyncToState\n"; } this.m_BuiltinAnnotations = new List<AInfo>(); this.m_ScriptAnnotations = new List<AInfo>(); for (int i = 0; i < annotations.Length; i++) { if (AnnotationWindow.s_Debug) { string text2 = text; text = string.Concat(new object[] { text2, " same as below: icon ", annotations[i].iconEnabled, " gizmo ", annotations[i].gizmoEnabled, "\n" }); } bool gizmoEnabled = annotations[i].gizmoEnabled == 1; bool iconEnabled = annotations[i].iconEnabled == 1; AInfo aInfo = new AInfo(gizmoEnabled, iconEnabled, annotations[i].flags, annotations[i].classID, annotations[i].scriptClass); if (aInfo.m_ScriptClass == string.Empty) { this.m_BuiltinAnnotations.Add(aInfo); if (AnnotationWindow.s_Debug) { string text2 = text; text = string.Concat(new object[] { text2, " ", BaseObjectTools.ClassIDToString(aInfo.m_ClassID), ": icon ", aInfo.m_IconEnabled, " gizmo ", aInfo.m_GizmoEnabled, "\n" }); } } else { this.m_ScriptAnnotations.Add(aInfo); if (AnnotationWindow.s_Debug) { string text2 = text; text = string.Concat(new object[] { text2, " ", annotations[i].scriptClass, ": icon ", aInfo.m_IconEnabled, " gizmo ", aInfo.m_GizmoEnabled, "\n" }); } } } this.m_BuiltinAnnotations.Sort(); this.m_ScriptAnnotations.Sort(); this.m_RecentAnnotations = new List<AInfo>(); Annotation[] recentlyChangedAnnotations = AnnotationUtility.GetRecentlyChangedAnnotations(); int num = 0; while (num < recentlyChangedAnnotations.Length && num < 5) { AInfo aInfo2 = this.GetAInfo(recentlyChangedAnnotations[num].classID, recentlyChangedAnnotations[num].scriptClass); if (aInfo2 != null) { this.m_RecentAnnotations.Add(aInfo2); } num++; } this.m_SyncWithState = false; if (AnnotationWindow.s_Debug) { Debug.Log(text); } }
private void SetIconState(AInfo ainfo) { AnnotationUtility.SetIconEnabled(ainfo.m_ClassID, ainfo.m_ScriptClass, !ainfo.m_IconEnabled ? 0 : 1); SceneView.RepaintAll(); }
private void DrawListElement(Rect rect, bool even, AInfo ainfo) { if (ainfo == null) { Debug.LogError((object) "DrawListElement: AInfo not valid!"); } else { float num1 = 17f; float a = 0.3f; bool changed = GUI.changed; bool enabled = GUI.enabled; Color color = GUI.color; GUI.changed = false; GUI.enabled = true; GUIStyle style = !even ? AnnotationWindow.m_Styles.listOddBg : AnnotationWindow.m_Styles.listEvenBg; GUI.Label(rect, GUIContent.Temp(string.Empty), style); Rect position1 = rect; position1.width = (float) ((double) rect.width - 64.0 - 22.0); GUI.Label(position1, ainfo.m_DisplayText, AnnotationWindow.m_Styles.listTextStyle); float num2 = 16f; Rect position2 = new Rect(rect.width - 64f, rect.y + (float) (((double) rect.height - (double) num2) * 0.5), num2, num2); Texture texture = (Texture) null; if (ainfo.m_ScriptClass != string.Empty) { texture = (Texture) EditorGUIUtility.GetIconForObject(EditorGUIUtility.GetScript(ainfo.m_ScriptClass)); Rect position3 = position2; position3.x += 18f; ++position3.y; position3.width = 1f; position3.height = 12f; GUI.color = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.13f) : new Color(0.0f, 0.0f, 0.0f, 0.33f); GUI.DrawTexture(position3, (Texture) EditorGUIUtility.whiteTexture, ScaleMode.StretchToFill); GUI.color = Color.white; Rect rect1 = position2; rect1.x += 18f; // ISSUE: explicit reference operation // ISSUE: variable of a reference type Rect& local = @rect1; // ISSUE: explicit reference operation double y = (double) (^local).y; // ISSUE: explicit reference operation (^local).y = (float) y; rect1.width = 9f; if (GUI.Button(rect1, this.iconSelectContent, AnnotationWindow.m_Styles.iconDropDown)) { UnityEngine.Object script = EditorGUIUtility.GetScript(ainfo.m_ScriptClass); if (script != (UnityEngine.Object) null) { this.m_LastScriptThatHasShownTheIconSelector = ainfo.m_ScriptClass; if (IconSelector.ShowAtPosition(script, rect1, true)) { IconSelector.SetMonoScriptIconChangedCallback(new IconSelector.MonoScriptIconChangedCallback(this.MonoScriptIconChanged)); GUIUtility.ExitGUI(); } } } } else if (ainfo.HasIcon()) texture = (Texture) AssetPreview.GetMiniTypeThumbnailFromClassID(ainfo.m_ClassID); if ((UnityEngine.Object) texture != (UnityEngine.Object) null) { if (!ainfo.m_IconEnabled) { GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, a); string empty = string.Empty; } this.iconToggleContent.image = texture; if (GUI.Button(position2, this.iconToggleContent, GUIStyle.none)) { ainfo.m_IconEnabled = !ainfo.m_IconEnabled; this.SetIconState(ainfo); } GUI.color = color; } if (GUI.changed) { this.SetIconState(ainfo); GUI.changed = false; } GUI.enabled = true; GUI.color = color; if (ainfo.HasGizmo()) { string tooltip = "Show/Hide Gizmo"; Rect position3 = new Rect(rect.width - 23f, rect.y + (float) (((double) rect.height - (double) num1) * 0.5), num1, num1); ainfo.m_GizmoEnabled = GUI.Toggle(position3, ainfo.m_GizmoEnabled, new GUIContent(string.Empty, tooltip), AnnotationWindow.m_Styles.toggle); if (GUI.changed) this.SetGizmoState(ainfo); } GUI.enabled = enabled; GUI.changed = changed; GUI.color = color; } }
private void SyncToState() { Annotation[] annotations = AnnotationUtility.GetAnnotations(); string str = string.Empty; if (AnnotationWindow.s_Debug) str += "AnnotationWindow: SyncToState\n"; this.m_BuiltinAnnotations = new List<AInfo>(); this.m_ScriptAnnotations = new List<AInfo>(); for (int index = 0; index < annotations.Length; ++index) { if (AnnotationWindow.s_Debug) str = str + " same as below: icon " + (object) annotations[index].iconEnabled + " gizmo " + (object) annotations[index].gizmoEnabled + "\n"; AInfo ainfo = new AInfo(annotations[index].gizmoEnabled == 1, annotations[index].iconEnabled == 1, annotations[index].flags, annotations[index].classID, annotations[index].scriptClass); if (ainfo.m_ScriptClass == string.Empty) { this.m_BuiltinAnnotations.Add(ainfo); if (AnnotationWindow.s_Debug) str = str + " " + BaseObjectTools.ClassIDToString(ainfo.m_ClassID) + ": icon " + (object) ainfo.m_IconEnabled + " gizmo " + (object) ainfo.m_GizmoEnabled + "\n"; } else { this.m_ScriptAnnotations.Add(ainfo); if (AnnotationWindow.s_Debug) str = str + " " + annotations[index].scriptClass + ": icon " + (object) ainfo.m_IconEnabled + " gizmo " + (object) ainfo.m_GizmoEnabled + "\n"; } } this.m_BuiltinAnnotations.Sort(); this.m_ScriptAnnotations.Sort(); this.m_RecentAnnotations = new List<AInfo>(); Annotation[] changedAnnotations = AnnotationUtility.GetRecentlyChangedAnnotations(); for (int index = 0; index < changedAnnotations.Length && index < 5; ++index) { AInfo ainfo = this.GetAInfo(changedAnnotations[index].classID, changedAnnotations[index].scriptClass); if (ainfo != null) this.m_RecentAnnotations.Add(ainfo); } this.m_SyncWithState = false; if (!AnnotationWindow.s_Debug) return; Debug.Log((object) str); }
public async Task <IActionResult> ConfirmAppointment([FromBody] AInfo info) { byte[] newRowVersion = null; try { var appointment = await _dbContext.Appointments.AsNoTracking().Include(a => a.Doctor).Include(a => a.Info).SingleOrDefaultAsync(a => a.Id == info.id); if (appointment == null) { return(Ok("Fail")); } bool update = false; if (appointment.Status == "Confirmed") { update = true; } appointment.RowVersion = info.rowVersion; appointment.Status = "Confirmed"; var start = DateTime.ParseExact(info.date + " " + info.start, "yyyy-MM-dd HH:mm", null); appointment.Start = start; appointment.End = start.AddMinutes(info.duration); appointment.Info.AdditionalInfo = info.info; var appointments = _dbContext.Appointments.AsNoTracking().Include(ft => ft.Doctor) .Where(a => a.Status == "Confirmed" && a.Doctor.Name == appointment.Doctor.Name && a.Start.Date == appointment.Start.Date); var intersectingElements = CalculateIntersectingElements(appointment, appointments); if (intersectingElements.Count > 0) { return(Ok("Intersection in time")); } if (!update) { appointment.EventId = Guid.NewGuid().ToString("N"); } _dbContext.Appointments.Update(appointment); _dbContext.SaveChanges(); newRowVersion = appointment.RowVersion; Event newEvent = new Event() { Id = appointment.EventId, Summary = appointment.Info.PatientName + " - " + appointment.Doctor.Name, Description = "Procedure: " + appointment.Info.AdditionalInfo + "\nDoctor Name: " + appointment.Doctor.Name + "\nPatient Name: " + appointment.Info.PatientName, //Attendees = new EventAttendee[] //{ // new EventAttendee{ DisplayName = info.patient, Email = "" }, // new EventAttendee{ DisplayName = info.doctor, Email = "" }, //}, Start = new EventDateTime() { DateTime = appointment.Start, }, End = new EventDateTime() { DateTime = appointment.End, } }; if (update) { var eventId = appointment.EventId; var request = _calendar.Service.Events.Update(newEvent, _calendar.CalendarId, eventId); Event createdEvent = request.Execute(); } else { var request = _calendar.Service.Events.Insert(newEvent, _calendar.CalendarId); Event createdEvent = await request.ExecuteAsync(); } } catch (DbUpdateConcurrencyException) { return(Ok("Fail")); } return(Ok(new { status = "Confirmed", newRowVersion = newRowVersion })); }