Exemple #1
0
        public ActionResult UserLogin(string assessmentID)
        {
            ExamLogin login = new ExamLogin();

            login.assessmentid = assessmentID;
            return(PartialView("UserLogin", login));
        }
Exemple #2
0
        public ActionResult PostLogin(ExamLogin login, FormCollection form)
        {
            string LogoutURL = ConfigurationManager.AppSettings["WebUIUrl"];

            string result = Failed;

            try
            {
                string username = Convert.ToString(form["username"]);
                string password = Convert.ToString(form["password"]);
                login.assessmentid = Convert.ToString(form["assessmentID"]);
                if (!string.IsNullOrEmpty(username))
                {
                    string apiUrl = ConfigurationManager.AppSettings["WebApiUrl"];

                    HttpClient client = new HttpClient();
                    //HttpContent inputContent = new StringContent(Encoding.UTF8, "application/json");
                    HttpResponseMessage response = client.GetAsync(apiUrl + "/Exam/ValidateExaminer?username="******"&password="******"&assessmentID=" + login.assessmentid).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        result      = response.Content.ReadAsStringAsync().Result;
                        APIResponse = JsonConvert.DeserializeObject <APIResponse>(result);
                    }
                    if (APIResponse.Result)
                    {
                        System.Web.HttpContext.Current.Response.Cookies.Clear();
                        System.Web.HttpContext.Current.Session["userid"] = login.username;
                        FormsAuthentication.SetAuthCookie(login.username, false);
                        Session["LoginAssessmentID"] = login.assessmentid;
                        return(RedirectToAction("Register", "ExamLogin"));
                    }
                }
                return(Redirect(LogoutURL));
            }
            catch (Exception ex)
            {
                return(Redirect(LogoutURL));
            }
        }