public ActionResult Login(LoginUser user) { if (ModelState.IsValid) { AdobeConnectXmlAPI con = new AdobeConnectXmlAPI(); StatusInfo sInfo; if (con.Login(user.Username, user.Password, out sInfo)) { int id = int.Parse(con.GetUserInfo().user_id); Identity Id = new Identity( id , user.Username, "T"); DateTime expire = DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(Id.ID, user.Username, DateTime.Now, expire, false, Id.GetUserData()); string hashTicket = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashTicket); HttpContext.Response.Cookies.Add(cookie); UserSession userSession = new UserSession(con.GetMyMeetings(), con.GetUserInfo()); using (AdobeConnectDB _db = new AdobeConnectDB()) { var check = _db.AdobeUserInfo.Where(u => u.Username == user.Username).FirstOrDefault(); if (check == null) { var newlogin = new LoginUser(); newlogin.Username = user.Username; newlogin.Password = user.Password; newlogin.Id = id; _db.AdobeUserInfo.Add(newlogin); _db.SaveChanges(); } else { check = user; _db.SaveChanges(); } } Session["UserSession"] = userSession; } else { return View("Login"); } } return RedirectToAction("Index", "Dashboard"); }
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) > 50) { 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; } } } }
public bool Delete(string id) { int Id = int.Parse(id); using (AdobeConnectDB _db = new AdobeConnectDB()){ //querying the data for the population of the calandar object for deletion List<Appointment> query = new List<Appointment>(); try { query = (from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet).ToList(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } //var query = from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet; foreach (Appointment res in query){ _db.Appointments.Remove(res); } if (_db.SaveChanges()>0) { Clients.All.removeSelf(Id); return true; } } return false; }
/// <summary> /// An overloaded function of delete, handels multiple events /// </summary> /// <param name="id">The id of the event to be deleted</param> /// <param name="response">True if all events are to be deleted, false if one is to be deleted</param> /// <returns>True if deletion was sucessful, false if not</returns> public bool Delete(string id, bool response) { int Id = int.Parse(id); using (AdobeConnectDB _db = new AdobeConnectDB()) { //querying the data for the population of the calandar object for deletion List<Appointment> query = new List<Appointment>(); //if we do want to delete all instances of the appointment if (response == true) { //holds the initial appointment from which the repId is found List<Appointment> initial = new List<Appointment>(); //get the ititial appointment try { initial = (from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet).ToList(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } //get the list of the repeating appointments try { string repititionId = initial[0].repititionId; query = (from appointmnet in _db.Appointments where appointmnet.repititionId == repititionId select appointmnet).ToList(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } } else { try { query = (from appointmnet in _db.Appointments where appointmnet.id == Id select appointmnet).ToList(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e); } } //iterate through the list of appointments and delete them all foreach (Appointment res in query) { _db.Appointments.Remove(res); } //check and see if appointments were deleted if (_db.SaveChanges() > 0) { //Clients.All.removeSelf(Id); foreach(Appointment identify in query) Clients.All.removeSelf(identify.id); return true; } } 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) > 50) { 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; } } } }