public ActionResult New(FormCollection frm) { var model = new bat.logic.ViewModels.Lessons.New(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var accInfo = logic.Helpers.UserAccountInfo.Get(user.ID); if (!accInfo.IsTeacher || !accInfo.IsEnabled) { return(RedirectToRoute("home")); } model = _lessonsService.SaveNew(frm, user.ID); } catch (Exception ex) { ViewBag.Error = ex.Message; TempData["Error"] = ex.Message; } return(RedirectToAction("Index", new { id = model.lesson.ID })); }
public ActionResult Index( string type, string firstname, string lastname, string email, string password) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user != null) { return(RedirectToRoute("home")); } var model = new bat.logic.ViewModels.Homepage.Landing(); try { ViewBag.firstName = firstname; ViewBag.lastName = lastname; ViewBag.email = email; model = _homeService.Signup(Convert.ToInt32(type), firstname, lastname, email, password); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Login(auth.GetUser(email, password)); return(RedirectToRoute("home")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Landing", model)); } }
public ActionResult Join(int id) { var model = new bat.logic.ViewModels.Lessons.Join(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } model = _lessonsService.LoadJoin(id, user.ID); if (!model.CanContinue) { return(RedirectToAction("Index", "Lessons", new { id = id })); } } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult Cancel(int id, FormCollection frm) { var model = new logic.ViewModels.Lessons.Cancel(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var accInfo = logic.Helpers.UserAccountInfo.Get(user.ID); if (!accInfo.IsTeacher) { return(RedirectToRoute("home")); } model = _lessonsService.LoadCancel(id, user.ID); _lessonsService.SaveCancel(id, user.ID, frm); } catch (WrongAccountException) { return(RedirectToRoute("home")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Error", model)); } return(RedirectToAction("Index", "Home")); }
public ActionResult Leave(int lessonid, int studentid, FormCollection frm) { var model = new bat.logic.ViewModels.Lessons.Leave(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } model = _lessonsService.LoadLeave(lessonid, user.ID); if (!model.CanContinue) { return(RedirectToAction("Index", "Lessons", new { id = lessonid })); } _lessonsService.SaveLeave(lessonid, studentid); return(RedirectToRoute("home")); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(RedirectToRoute("home")); }
public ActionResult DeleteMember(int id) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var model = new bat.logic.ViewModels.Profile.EditMember(); try { var accInfo = logic.Helpers.UserAccountInfo.Get(user.ID); if (accInfo.IsTeacher) { RedirectToAction("Index"); } model = _profileService.DeleteEditMember(id, user.ID); } catch (WrongAccountException) { return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(RedirectToAction("Index")); }
public ActionResult New(string date) { var model = new bat.logic.ViewModels.Lessons.New(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var accInfo = logic.Helpers.UserAccountInfo.Get(user.ID); if (!accInfo.IsTeacher || !accInfo.IsEnabled) { return(RedirectToRoute("home")); } model = _lessonsService.LoadNew(date); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult New(FormCollection frm) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var model = new bat.logic.ViewModels.Profile.New(); try { var accInfo = logic.Helpers.UserAccountInfo.Get(user.ID); if (accInfo.IsTeacher) { return(RedirectToAction("Index")); } model = _profileService.SaveNew(user.ID, frm); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult LessonDetails(int id) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var model = new bat.logic.ViewModels.Profile.LessonDetails(); try { model = _profileService.LoadLessonDetails(id, user.ID); } catch (WrongAccountException) { return(RedirectToRoute("home")); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult Edit(string FirstName, string LastName, string Description, string Qualifications, int?Rate, HttpPostedFileBase Picture) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var model = new bat.logic.ViewModels.Profile.Edit(); try { model = _profileService.ProfileEditSave( user.ID, FirstName, LastName, Description, Qualifications, Rate, Picture); return(RedirectToAction("Index")); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult logout() { ViewData.Clear(); TempData.Clear(); Session.Clear(); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Logout(); return(RedirectToRoute("home")); }
public ActionResult ForgotPassword() { ViewData.Clear(); TempData.Clear(); Session.Clear(); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Logout(); return(View()); }
public string UploadtoCloud(FormDataCollection formData) { var user = new logic.Rules.Authentication(HttpContext.Current.Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { throw new Exception("Unauthorised access."); } return(logic.Rules.ResourceManagement.UploadResourceImage(formData)); }
public string Getattachment(FormDataCollection formData) { var user = new logic.Rules.Authentication(HttpContext.Current.Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { throw new Exception("Unauthorised access."); } return(_lessonsService.GetImageStream(Convert.ToInt32(formData["attachmentid"]))); }
public ActionResult Login() { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user != null) { return(RedirectToRoute("home")); } return(View()); }
public string Getday(FormDataCollection formData) { var user = new logic.Rules.Authentication(HttpContext.Current.Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { throw new Exception("Unauthorised access."); } var json = new JavaScriptSerializer(); return(json.Serialize(_homeService.GDay(Convert.ToInt32(formData["userid"]), formData["date"]))); }
public ActionResult Index() { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInAdminUser(); if (user == null) { return(RedirectToAction("Landing")); } return(RedirectToAction("Index", "Admin")); } var model = new bat.logic.ViewModels.Homepage.Dashboard(); try { var accInfo = _accService.Get(user.ID); if (accInfo.IsTeacher && (string.IsNullOrEmpty(accInfo.account.Description) || string.IsNullOrEmpty(accInfo.account.Qualifications))) { return(RedirectToAction("Complete", "Profile")); } model = _homeService.LoadDashboard(accInfo.accountType, accInfo.account.ID); model.AccInfo = accInfo; } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Error")); } switch (model.AccInfo.accountType) { case Types.AccountTypes.Student: return(View("DashStudent", model)); case Types.AccountTypes.Teacher: return(View("DashTeacher", model)); } // maybe for admin later return(View(model)); }
public ActionResult ListLessons(string subject) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); var model = new bat.logic.ViewModels.Homepage.SubjectList(); try { model = _homeService.LoadSubjectList(subject, user?.ID); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult Upload(int id, HttpPostedFileBase data, string title) { try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } _lessonsService.UploadImage(id, title, data, user.ID); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(RedirectToAction("Index", new { id = id })); }
public ActionResult ResetPassword(string t) { var model = new bat.logic.ViewModels.Homepage.ResetPassword(); try { ViewData.Clear(); TempData.Clear(); Session.Clear(); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Logout(); model = _passwdService.VerifyToken(t); } catch (Exception ex) { ViewBag.Response = ex.Message; } return(View(model)); }
public ActionResult ResetPassword(string token, string txtPassword1, string txtPassword2) { var model = new bat.logic.ViewModels.Homepage.ResetPassword(); try { model = _passwdService.VerifyToken(token); var account = _passwdService.ChangePassword(token, txtPassword1, txtPassword2); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Login(account); return(RedirectToRoute("home")); } catch (Exception ex) { ViewBag.ErrMsg = ex.Message; } return(View(model)); }
public string Upload(FormDataCollection formData) { var user = new logic.Rules.Authentication(HttpContext.Current.Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { throw new Exception("Unauthorised access."); } var json = new JavaScriptSerializer(); try { return(json.Serialize(_lessonsService.UploadEncodedImage(Convert.ToInt32(formData["lessonid"]), user.ID, formData["title"], formData["data"]))); } catch (Exception e) { return(json.Serialize(e.Message)); } }
public ActionResult LoginSignup(string returnUrl) { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); //So that the user can be referred back to where they were when they click logon if (string.IsNullOrEmpty(returnUrl) && Request.UrlReferrer != null) { returnUrl = Server.UrlEncode(Request.UrlReferrer.PathAndQuery); } if (user != null) { return(RedirectToRoute("home")); } else if (Url.IsLocalUrl(returnUrl) && !string.IsNullOrEmpty(returnUrl)) { ViewBag.ReturnURL = returnUrl; } return(View()); }
public ActionResult Index() { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var model = new bat.logic.ViewModels.Profile.Profile(); try { model.AccInfo = logic.Helpers.UserAccountInfo.Get(user.ID); } catch (Exception ex) { ViewBag.Error = ex.Message; } return(View(model)); }
public ActionResult Swap(int id) { var model = new logic.Rules.Swap(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } model.Load(user, id); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Login(model.account); } catch (Exception ex) { ViewBag.LoginErrMsg = ex.Message; } return(RedirectToRoute("home")); }
public string UploadFile() { var user = new logic.Rules.Authentication(HttpContext.Current.Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { throw new Exception("Unauthorised access."); } if (HttpContext.Current.Request.Files.AllKeys.Any()) { // Get the uploaded image from the Files collection var httpPostedFile = HttpContext.Current.Request.Files["UploadedImage"]; if (httpPostedFile != null) { // Validate the uploaded image(optional) return("success"); } return("fail"); } return("fail"); }
public ActionResult Reschedule(int id) { var model = new logic.ViewModels.Lessons.Reschedule(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } var accInfo = logic.Helpers.UserAccountInfo.Get(user.ID); if (!accInfo.IsTeacher) { return(RedirectToRoute("home")); } model = _lessonsService.LoadReschedule(id, user.ID); if (model.lesson.CancelledDate.HasValue) { return(RedirectToAction("Index", new { id = id })); } return(View(model)); } catch (WrongAccountException) { return(RedirectToRoute("home")); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Error", model)); } }
public ActionResult Register(string type, string firstname, string lastname, string email, string password, string returnUrl) { try { ViewBag.firstName = firstname; ViewBag.lastName = lastname; ViewBag.email = email; var rs = _homeService.Signup(Convert.ToInt32(type), firstname, lastname, email, password); var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Login(auth.GetUser(email, password)); } catch (Exception ex) { ViewBag.Error = ex.Message; return(View("LoginSignup")); } //returnURL needs to be decoded string decodedUrl = ""; if (!string.IsNullOrEmpty(returnUrl)) { decodedUrl = Server.UrlDecode(returnUrl); } //Login logic... if (Url.IsLocalUrl(decodedUrl)) { return(Redirect(decodedUrl)); } else { return(RedirectToRoute("home")); } }
public ActionResult login(string txtUsername, string txtPassword, string returnUrl) { // not already logged in, so continue Session.Clear(); System.Threading.Thread.Sleep(250); // slight delay to deter bots try { var auth = new logic.Rules.Authentication(Request.GetOwinContext()); auth.Login(auth.GetUser(txtUsername, txtPassword)); } catch (Exception ex) { ViewBag.LoginErrMsg = ex.Message; return(View()); } //returnURL needs to be decoded string decodedUrl = ""; if (!string.IsNullOrEmpty(returnUrl)) { decodedUrl = Server.UrlDecode(returnUrl); } //Login logic... if (Url.IsLocalUrl(decodedUrl)) { return(Redirect(decodedUrl)); } else { return(RedirectToRoute("home")); } }
public ActionResult Index(int id) { var model = new bat.logic.ViewModels.Lessons.View(); try { var user = new logic.Rules.Authentication(Request.GetOwinContext()).GetLoggedInUser(); if (user == null) { return(RedirectToRoute("home")); } model = _lessonsService.LoadView(id, user.ID); if (model.lesson.CancelledDate.HasValue) { return(View("CancelledLesson", model)); } if (logic.Helpers.WebRTC.WebRTCAvailable()) { model = _lessonsService.GenerateTokBoxToken(model, user.ID, user.Email); return(View("ViewTokBox", model)); } else { return(View("WebRTCUnavailable", model)); } // no longer using zoom //if (!model.CurrentlyAZoomUser) //{ // model.CheckZoomUser(); // return View("NewZoomUserAccount", model); //} //switch (model.accountType) //{ // case Types.AccountTypes.Student: // if (!model.LessonReady) // return View("ZoomLessonHostNotReady", model); // break; // case Types.AccountTypes.Teacher: // model.CreateZoomMeeting(); // return View("ViewZoom", model); // default: // throw new Exception("Invalid account type."); //} } //catch (ZoomException ex) when (ex.Code == bat.logic.Constants.Zoom.ErrorCode_CannotCreateMeeting) //{ // return View("NewZoomUserAccount", model); //} catch (Exception ex) { ViewBag.Error = ex.Message; return(View("Error", model)); } }