public CalendarData ConstructObject(Appointment appointment, string id, string jsDate) { Clients.Caller.date(jsDate); DateTime Date = DateTime.Parse(jsDate); CalendarData callendarData = new CalendarData(); callendarData.id = appointment.id; callendarData.userId = appointment.userId; callendarData.title = appointment.title; callendarData.url = appointment.url; callendarData.color = "#c4afb9"; callendarData.adobeUrl = appointment.adobeUrl; callendarData.roomSize = appointment.roomSize; callendarData.start = appointment.start; callendarData.end = appointment.end; callendarData.editable = true; callendarData.open = true; callendarData.archived = false; callendarData.isRep = appointment.isRep; callendarData.repititionId = appointment.repititionId; callendarData.endRepDate = appointment.endRepDate; callendarData.repititionType = appointment.repititionType; //Optimize check so it won't take as many computational cycles. /* if (!checkHost(id,callendarData.title)) * { * callendarData.color = "#d3bf96"; * callendarData.url = ""; * callendarData.editable = false; * } * * if (checkHost(id, callendarData.title)) * { * if (Date < callendarData.start) * { * callendarData.color = "#bac7c3"; * callendarData.open = false; * callendarData.url = ""; * } * * } * * if (Date > callendarData.end) * { * callendarData.color = "gray"; * callendarData.open = false; * callendarData.url = ""; * callendarData.editable = false; * callendarData.archived = true; * }*/ return(callendarData); }
public bool AddAppointment(bool isChecked, bool isUpdate, string roomId, string userId, string name, string roomSize, string url, string path, string JsdateTime, string Jsmin, bool jsHandle) { DateTime date = DateTime.Parse(JsdateTime); int endtime = int.Parse(Jsmin); DateTime end = date.AddMinutes(endtime); if (int.Parse(roomSize) > 70) { return(false); } if (!isUpdate) { using (AdobeConnectDB _db = new AdobeConnectDB()) { Appointment appointment = new Appointment(); CalendarData callendarData = new CalendarData(); appointment.userId = userId; appointment.title = name; appointment.roomSize = int.Parse(roomSize); appointment.url = path; appointment.adobeUrl = url; appointment.start = date; appointment.end = end; if (isChecked) { _db.Appointments.Add(appointment); _db.SaveChanges(); Clients.All.addEvent(appointment, isChecked, isUpdate, jsHandle); return(true); } else { Clients.Caller.addEvent(appointment, isChecked, isUpdate, jsHandle); return(false); } } } else { int Id = int.Parse(roomId); using (AdobeConnectDB _db = new AdobeConnectDB()) { var query = (from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet).Single(); query.start = date; query.roomSize = int.Parse(roomSize); query.title = name; query.adobeUrl = url; query.url = path; query.start = date; query.end = end; if (isChecked) { _db.SaveChanges(); Clients.All.addEvent(query, isChecked, true, jsHandle); return(true); } else { Clients.Caller.addEvent(query, isChecked, isUpdate, jsHandle); return(false); } } } }
/// <summary> /// Overloaded function of AddAppointment /// </summary> /// <param name="isChecked"></param> /// <param name="isUpdate"></param> /// <param name="roomId"></param> /// <param name="userId"></param> /// <param name="name"></param> /// <param name="roomSize"></param> /// <param name="url"></param> /// <param name="path"></param> /// <param name="JsdateTime"></param> /// <param name="Jsmin"></param> /// <param name="jsHandle"></param> /// <param name="isMultiple"></param> /// <param name="repId"></param> /// <param name="JSendRepDate"></param> /// <param name="repType"></param> /// <param name="changeAll"></param> /// <returns></returns> public bool AddAppointment(bool isChecked, bool isUpdate, string roomId, string userId, string name, string roomSize, string url, string path, string JsdateTime, string Jsmin, bool jsHandle, bool isMultiple, string repId, string JSendRepDate, string repType, bool changeAll) { DateTime date = DateTime.Parse(JsdateTime); int endtime = int.Parse(Jsmin); DateTime end = date.AddMinutes(endtime); DateTime endRepTime; //if there is no end rep time if (JSendRepDate == "") { endRepTime = end; } else { endRepTime = DateTime.Parse(JSendRepDate); } if (int.Parse(roomSize) > 70) { return(false); } using (AdobeConnectDB _db = new AdobeConnectDB()) { if (!isUpdate) { Appointment appointment = new Appointment(); CalendarData callendarData = new CalendarData(); if (isMultiple) { appointment.userId = userId; appointment.title = name; appointment.roomSize = int.Parse(roomSize); appointment.url = path; appointment.adobeUrl = url; appointment.start = date; appointment.end = end; appointment.endRepDate = endRepTime; appointment.repititionId = repId; appointment.isRep = isMultiple; appointment.repititionType = repType; } else { appointment.userId = userId; appointment.title = name; appointment.roomSize = int.Parse(roomSize); appointment.url = path; appointment.adobeUrl = url; appointment.start = date; appointment.end = end; appointment.endRepDate = date; appointment.repititionId = null; appointment.isRep = isMultiple; appointment.repititionType = repType; } if (isChecked) { _db.Appointments.Add(appointment); _db.SaveChanges(); Clients.All.addEvent(appointment, isChecked, isUpdate, jsHandle); return(true); } else { Clients.Caller.addEvent(appointment, isChecked, isUpdate, jsHandle); return(false); } } //if it is indeed an update else { int Id = int.Parse(roomId); List <Appointment> query = new List <Appointment>(); //if it is not an update to a series of events if (!changeAll) { query = (from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet).ToList(); foreach (Appointment res in query) { res.start = date; res.roomSize = int.Parse(roomSize); res.title = name; res.adobeUrl = url; res.url = path; res.start = date; res.end = end; res.endRepDate = endRepTime; } } //if it is an update to a series of events else { Appointment first = new Appointment(); first = (from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet).Single(); string repititionId = first.repititionId; query = (from appointmnet in _db.Appointments where appointmnet.repititionType == repititionId select appointmnet).ToList(); foreach (Appointment res in query) { res.start = date; res.roomSize = int.Parse(roomSize); res.title = name; res.adobeUrl = url; res.url = path; res.start = date; res.end = end; res.endRepDate = endRepTime; } } if (isChecked) { _db.SaveChanges(); foreach (Appointment res in query) { Clients.All.addEvent(res, isChecked, true, jsHandle); } return(true); } else { foreach (Appointment res in query) { Clients.Caller.addEvent(res, isChecked, isUpdate, jsHandle); } return(false); } } } }