public ActionResult User_login_btn(string user_type, string role_id , string username, string curr_password) { try { string apiUrl; if (username != "" && curr_password != "" && role_id != "") { if (user_type != "1") { if (Convert.ToInt32(role_id) == 1) { Session["apiUrl"] = "http://localhost:21681/api/userAPI/Getlogin_user?username=" + username + "&curr_password=" + curr_password + "&role=" + role_id; } //else if (Convert.ToInt32(role_id) == 5) //{ // Session["apiUrl"] = "http://localhost:21681/api/userAPI/Getlogin_user_warehouse?username=" + username + "&curr_password=" + curr_password + "&role=" + role_id; //} //else if (Convert.ToInt32(role_id) == 6) //{ // Session["apiUrl"] = "http://localhost:21681/api/userAPI/Getlogin_user?username=" + username + "&curr_password=" + curr_password + "&role=" + role_id; //} //else if (Convert.ToInt32(role_id) == 7) //{ // Session["apiUrl"] = "http://localhost:21681/api/userAPI/Getlogin_user?username=" + username + "&curr_password=" + curr_password + "&role=" + role_id; //} else { } // apiUrl = "http://localhost:21681/api/userAPI/Getlogin_user?username=" + username + "&curr_password=" + curr_password + "&role=" + role_id; var k = Session["apiUrl"]; using (var client = new HttpClient()) { userregistration login = new userregistration(); HttpResponseMessage Response = client.GetAsync(Session["apiUrl"] + string.Format("")).Result; if (Response.IsSuccessStatusCode) { var EmpResponse = Response.Content.ReadAsStringAsync().Result; login = JsonConvert.DeserializeObject(EmpResponse); Session["username"] = Convert.ToString(login.username); var a = Session["username"]; Session["role_id"]= Convert.ToInt32(login.role_id); //Session["mobile_no"] = Convert.ToString(login.mobile_no); ////Session["user_type"] = Convert.ToString(login.user_type); //Session["name"] = Convert.ToString(login.name); //Session["email"] = Convert.ToString(login.email); if (Session["username"] != null) { //get_user_type(username, curr_password, role_id); //return RedirectToAction("user_dashboard"); if (Convert.ToInt32(Session["role_id"]) == 1) { return RedirectToAction("admin_dashboard", "Malavi"); } //else if (Convert.ToInt32(Session["role_id"]) == 1 && Convert.ToString(Session["role_id"]) == "warehouse") //{ //} //else if (Convert.ToString(Session["role_id"]) == "5") //{ // return RedirectToAction("dashboard", "local_manufacturer"); //} //else if (Convert.ToString(Session["role_id"]) == "10") //{ // return RedirectToAction("retailer_dashboard", "local_manufacturer"); //} //else if (Convert.ToString(Session["role_id"]) == "9") //{ // return RedirectToAction("wholesellar_dashboard", "local_manufacturer"); //} //else if (Convert.ToString(Session["role_id"]) == "8") //{ // return RedirectToAction("warehouse_dashboard", "local_manufacturer"); //} else { ViewBag.ErrorMessage = "Email not found or matched"; return RedirectToAction("Login"); } } else { ViewBag.ErrorMessage = "Email not found or matched"; return RedirectToAction("Login"); } } else { username = ""; curr_password = ""; return RedirectToAction("Login"); } } } else { apiUrl = "http://localhost:21681/api/userAPI/Getlogin_admin?username=" + username + "&curr_password=" + curr_password + "&role=" + role_id; using (var client = new HttpClient()) { userregistration login = new userregistration(); HttpResponseMessage Response = client.GetAsync(apiUrl + string.Format("")).Result; if (Response.IsSuccessStatusCode) { var EmpResponse = Response.Content.ReadAsStringAsync().Result; login = JsonConvert.DeserializeObject(EmpResponse); Session["username"] = Convert.ToString(login.username); var a = Session["username"]; Session["mobile_no"] = Convert.ToString(login.mobile_no); //Session["user_type"] = Convert.ToString(login.user_type); Session["name"] = Convert.ToString(login.name); Session["email"] = Convert.ToString(login.email); if (Session["username"] != null) { get_user_type(username, curr_password, role_id); //return RedirectToAction("user_dashboard"); if (Convert.ToString(Session["role_id"]) == "1") { return RedirectToAction("admin_dashboard", "Malavi"); } //else if (Convert.ToString(Session["role_id"]) == "5") //{ // return RedirectToAction("dashboard", "local_manufacturer"); //} //else if (Convert.ToString(Session["role_id"]) == "10") //{ // return RedirectToAction("retailer_dashboard", "local_manufacturer"); //} //else if (Convert.ToString(Session["role_id"]) == "9") //{ // return RedirectToAction("wholesellar_dashboard", "local_manufacturer"); //} //else if (Convert.ToString(Session["role_id"]) == "8") //{ // return RedirectToAction("warehouse_dashboard", "local_manufacturer"); //} else { ViewBag.ErrorMessage = "Email not found or matched"; return RedirectToAction("Login"); } } else { ViewBag.ErrorMessage = "Email not found or matched"; return RedirectToAction("Login"); } } else { username = ""; curr_password = ""; return RedirectToAction("Login"); } } } } } catch (Exception ex) { } return View(); }