public ActionResult Invitations() { if (!string.IsNullOrEmpty(Convert.ToString(Session["ExamID"]))) { int SchoolID = Convert.ToInt32(Session["ExamID"]); int UType = Convert.ToInt32(Session["UserType"]); try { List <EmailModels> listQuestions = new List <EmailModels>(); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("emailnotifications/GetInvitations?SID=" + SchoolID + "&UType=" + UType).Result; if (response.IsSuccessStatusCode) { listQuestions = JsonConvert.DeserializeObject <List <EmailModels> >(response.Content.ReadAsStringAsync().Result); } ViewBag.listStatus = listQuestions; return(View()); } catch (Exception ex) { string error = ex.ToString().Trim(); return(View()); } } else { return(RedirectToAction("logins", "logins")); } }
/// <summary> /// Show list of Subjects /// </summary> /// <returns></returns> public ActionResult StandardsList() { if (!string.IsNullOrEmpty(Convert.ToString(Session["ExamID"]))) { int SchoolID = Convert.ToInt32(Session["ExamID"]); try { List <SubjectModel> listStandardList = new List <SubjectModel>(); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("Student/GetStandarsLookup?SchoolID=" + SchoolID).Result; if (response.IsSuccessStatusCode) { listStandardList = JsonConvert.DeserializeObject <List <SubjectModel> >(response.Content.ReadAsStringAsync().Result); } ViewBag.getChapterList = listStandardList; return(View()); } catch (Exception ex) { string error = ex.ToString().Trim(); return(RedirectToAction("logins", "logins")); } } else { return(RedirectToAction("logins", "logins")); } }
/// <summary> /// Profile page /// </summary> /// <returns></returns> public ActionResult Profile() { if (!string.IsNullOrEmpty(Convert.ToString(Session["ExamID"]))) { int SchoolID = Convert.ToInt32(Session["ExamID"]); try { List <Registration> listUserList = new List <Registration>(); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("Register/GetLogin?UserName="******"LoginUserName"] + "&Password="******"Password"]).Result; if (response.IsSuccessStatusCode) { listUserList = JsonConvert.DeserializeObject <List <Registration> >(response.Content.ReadAsStringAsync().Result); } ViewBag.getUserList = listUserList; return(View()); } catch (Exception ex) { string error = ex.ToString().Trim(); return(RedirectToAction("logins", "logins")); } } else { return(RedirectToAction("logins", "logins")); } }
public ActionResult Registration(Registration registration) { if (ModelState.IsValid) { HttpClient client = new HttpClient(); client.BaseAddress = new Uri(appKey.GetapiURL()); client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = client.PostAsync("/Registration/SaveRegistration", new StringContent(new JavaScriptSerializer().Serialize(registration), Encoding.UTF8, "application/json")).Result; if (response.IsSuccessStatusCode) { bool status = JsonConvert.DeserializeObject <bool>(response.Content.ReadAsStringAsync().Result); if (status) { TempData["notice"] = "Successfully registered"; } else { TempData["notice"] = "Failed to registered"; } } } ViewBag.UserTypeList = GetUserType(); return(View()); }
//[HttpPost] public ActionResult GetLogin(Home home) { List <Home> listHome = new List <Home>(); if (ModelState.IsValid) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("Register/GetLogin?UserName="******"&Password="******"").Result; if (response.IsSuccessStatusCode) { listHome = JsonConvert.DeserializeObject <List <Home> >(response.Content.ReadAsStringAsync().Result); } foreach (var item in listHome) { this.Session["UserId"] = item.UID; } if (listHome.Count > 0) { //1 --> Admin if (Convert.ToInt32(Session["UserType"]) == 1) { return(RedirectToAction("staff", "dashboard")); } // 2 --> Staff else if (Convert.ToInt32(Session["UserType"]) == 2) { return(RedirectToAction("staff", "dashboard")); } // 3 --> Student else { return(RedirectToAction("student", "dashboard")); } } else { return(RedirectToAction("logins", "logins")); } } else { return(RedirectToAction("logins", "logins")); } }
// GET: Subject public ActionResult Index(int ExamId) { try { List <SubjectModel> listsubject = new List <SubjectModel>(); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("subject/GetSubject?ExamId=" + ExamId).Result; if (response.IsSuccessStatusCode) { listsubject = JsonConvert.DeserializeObject <List <SubjectModel> >(response.Content.ReadAsStringAsync().Result); } ViewBag.getSubject = listsubject; return(View()); } catch (Exception ex) { string error = ex.ToString().Trim(); return(RedirectToAction("logins", "logins")); } }
//[HttpPost] public ActionResult GetLogin(Home home) { List <Home> listHome = new List <Home>(); if (ModelState.IsValid) { HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("Register/GetLogin?UserName="******"&Password="******"UserId"] = item.UID; this.Session["UserType"] = item.UserType; this.Session["LoginUserName"] = item.UserName; this.Session["Password"] = item.Password; this.Session["ExamID"] = item.SchoolID; this.Session["StandardID"] = item.StandardId; if (!string.IsNullOrEmpty(Convert.ToString(item.Location))) { TempData["ProfilePicture"] = item.Location; } else { TempData["ProfilePicture"] = string.Empty; } if (!string.IsNullOrEmpty(Convert.ToString(item.EmailId))) { this.Session["LoginEmailID"] = item.EmailId; } else { this.Session["LoginEmailID"] = string.Empty; } this.Session["Session_StandardID"] = item.StandardId; int DateDifference = (item.expire_on - Convert.ToDateTime("7/22/2018")).Days; if (DateDifference < 10) { this.Session["expire_on"] = DateDifference; } } if (listHome.Count > 0) { if (Convert.ToInt32(Session["UserType"]) == 1) { //1 --> Admin return(RedirectToAction("dashboard", "staff")); } else if (Convert.ToInt32(Session["UserType"]) == 2) { // 2 --> Staff return(RedirectToAction("dashboard", "staff")); } else if (Convert.ToInt32(Session["UserType"]) == 3) { // 3 --> Paid User return(RedirectToAction("dashboard", "student")); } else { // 4 --> Free User return(RedirectToAction("dashboard", "student")); } } else { return(RedirectToAction("logins", "logins")); } } else { return(RedirectToAction("logins", "logins")); } }
//DeleteAjaxStandrad public ActionResult DeleteAwarness(int ID) { try { List <SubjectModel> listsubject = new List <SubjectModel>(); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("settings/deleteAwarness?ID=" + ID).Result; if (response.IsSuccessStatusCode) { return(Json("true", JsonRequestBehavior.AllowGet)); } else { return(Json("false", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { string error = ex.ToString().Trim(); return(RedirectToAction("logins", "logins")); } }
public string UploadImage(IEnumerable files, QuestionModels model, string Hidden) { string path = string.Empty; string pic = string.Empty; string ext = string.Empty; string dataIs = string.Empty; int SID = Convert.ToInt32(Session["ExamID"]); int UID = Convert.ToInt32(Session["UserId"]); int UserType = Convert.ToInt32(Session["UserType"]); string _Date = DateTime.Now.Millisecond.ToString().Trim(); try { foreach (HttpPostedFileBase file in files) { if (Hidden.Equals("Status")) { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { pic = Path.GetFileName(file.FileName); ext = Path.GetExtension(file.FileName); path = Path.Combine(Server.MapPath("/images/Status/"), pic + ext); // file is uploaded file.SaveAs(path); } dataIs = Hidden + "|" + "/images/Status/" + pic + ext; } else if (Hidden.Equals("profile")) { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { pic = Path.GetFileName(SID + "_" + UID); ext = Path.GetExtension(file.FileName); path = Path.Combine(Server.MapPath("/images/UserProfile/"), pic + ext); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } // file is uploaded file.SaveAs(path); string Location = ConfigurationManager.AppSettings["Application_URL"].ToString().Trim() + "/images/UserProfile/" + pic + ext; try { if (!string.IsNullOrEmpty(Convert.ToString(Session["ExamID"]))) { int SchoolID = Convert.ToInt32(Session["ExamID"]); try { List <Registration> listEmailList = new List <Registration>(); HttpClient httpClient = new HttpClient(); httpClient.BaseAddress = new Uri(appKey.GetapiURL()); httpClient.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); var response = httpClient.GetAsync("Register/UpdateProfilePicture?SID=" + SID + "&UID=" + UID + "&UserType=" + UserType + "&Location=" + Location).Result; if (response.IsSuccessStatusCode) { dataIs = Hidden + "|" + "/images/UserProfile/" + pic + ext; } else { dataIs = "false"; } } catch (Exception ex) { string error = ex.ToString().Trim(); dataIs = "false"; } } else { dataIs = "false"; } } catch (Exception ex) { dataIs = ex.ToString().Trim(); } } dataIs = Hidden + "|" + "/images/UserProfile/" + pic + ext; } else { // Verify that the user selected a file if (file != null && file.ContentLength > 0) { string StandardId = Session["StandardId"].ToString().Trim(); string SubjectId = Session["SubjectId"].ToString().Trim(); string ChapterId = Session["ChapterId"].ToString().Trim(); pic = Path.GetFileName(StandardId + "_" + SubjectId + "_" + ChapterId + "_" + Hidden + "_" + _Date); ext = Path.GetExtension(file.FileName); path = Path.Combine(Server.MapPath("/images/profile/"), pic + ext); // file is uploaded file.SaveAs(path); } dataIs = Hidden + "|" + "/images/profile/" + pic + ext; } } return(dataIs); } catch (Exception ex) { return(ex.ToString().Trim()); } }