public ActionResult PageUser() { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); string pagename = @"/" + controllerName + @"/" + actionName; var page = (List <LP_Pages_Property>)Session["PageList"]; if (Session["LoggedIn"] != null && Helper.CheckPageAccess(pagename, page) && Session["ISADMIN"] != null && Convert.ToBoolean(Session["ISADMIN"].ToString()) == true) // if (Session["LOGGEDIN"] != null) { LP_PageUser_Property objpage = new LP_PageUser_Property(); objUserBll = new User_BLL(); objpage.PageList = Helper.ConvertDataTable <LP_Pages_Property>(objUserBll.GetAllPages()); User_Property objUserProperty = new User_Property(); objUserProperty.branchIdx = 1;//user logged in session branchIdx User_BLL objUser = new User_BLL(objUserProperty); var Data = JsonConvert.SerializeObject(objUser.ViewAll()); objpage.UserList = Helper.ConvertDataTable <User_Property>(objUser.ViewAll()); ViewBag.Pagelist = objpage.PageList; return(View(objpage)); } else { if (Session["LoggedIn"] == null) { return(RedirectToAction("Login", "Account")); } else { return(RedirectToAction("NotAuthorized", "Account")); } } }
public JsonResult GetAllUsers() { if (Session["LOGGEDIN"] != null) { try { objUserProperty = new User_Property(); objUserProperty.branchIdx = 1;//user logged in session branchIdx objUser = new User_BLL(objUserProperty); var Data = JsonConvert.SerializeObject(objUser.ViewAll()); return(Json(new { data = Data, success = true, statuscode = 200, count = Data.Length }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { data = ex.Message, success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { data = "Session Expired", success = false, statuscode = 400, count = 0 }, JsonRequestBehavior.AllowGet)); } }
public JsonResult Login(User_Property objUserPropertyNew) { objUserProperty = new User_Property(); objUserProperty.UserName = objUserPropertyNew.UserName.Trim(); objUserProperty.Password = objUserPropertyNew.Password.Trim(); objUserProperty.PageSize = 9999999; objUserProperty.PageNum = 1; objUserBLL = new User_BLL(objUserProperty); DataTable userDT = objUserBLL.ViewAll(); if (userDT.Rows.Count == 0) { //lblError.Visible = true; //lblError.Text = "Invalid Username Or Password"; return(Json(new { success = true, Login = false, statuscode = 404, msg = "Invaid Credentials" }, JsonRequestBehavior.AllowGet)); } else { try { SessionManager.CurrentUser.ID = Convert.ToInt32(userDT.Rows[0]["ID"].ToString()); //SessionManager.CurrentUser.LocationID = Convert.ToInt32(userDT.Rows[0]["Location_Setup_ID"].ToString()); //SessionManager.CurrentUser.Code = Convert.ToInt32(userDT.Rows[0]["code"].ToString()); //SessionManager.CurrentUser.DistributorID = Convert.ToInt32(userDT.Rows[0]["DistributorID"].ToString()); //SessionManager.CurrentUser.CompanyID = Convert.ToInt32(userDT.Rows[0]["CompanyID"].ToString()); SessionManager.CurrentUser.UserName = userDT.Rows[0]["UserName"].ToString(); SessionManager.CurrentUser.FirstName = userDT.Rows[0]["FirstName"].ToString(); SessionManager.CurrentUser.LastName = userDT.Rows[0]["LastName"].ToString(); SessionManager.CurrentUser.Email = userDT.Rows[0]["Email"].ToString(); SessionManager.CurrentUser.Password = userDT.Rows[0]["Password"].ToString(); //SessionManager.CurrentUser.Active = Convert.ToInt32(userDT.Rows[0]["IsActive"].ToString()); SessionManager.CurrentUser.InsertBy = Convert.ToInt32(userDT.Rows[0]["CreatedBy"].ToString()); SessionManager.CurrentUser.InsertionDate = Convert.ToDateTime(userDT.Rows[0]["DateCreated"]); SessionManager.CurrentUser.EmployeeID = Convert.ToInt32(userDT.Rows[0]["EmployeeID"]); Session["RoleID"] = Convert.ToInt32(userDT.Rows[0]["RoleId"].ToString()); Session["Emp_ID"] = Convert.ToInt32(userDT.Rows[0]["EmployeeID"]); //objUserRegionProperty = new User_Region_Property(); //objUserRegionProperty.UserId = Convert.ToInt32(SessionManager.CurrentUser.ID); //objUserRegionBLL = new User_Region_BLL(objUserRegionProperty); //DataTable dtRegionalUserLocations = objUserRegionBLL.GetRegionalUserLocationByUserIdBLL(); //if (dtRegionalUserLocations.Rows.Count > 0) //{ // SessionManager.CurrentUser.IsRegionalUser = true; // SessionManager.CurrentUser.RegionalLocationsDT = dtRegionalUserLocations; // locations = new List<string>(); // for (int i = 0; i < dtRegionalUserLocations.Rows.Count; i++) // { // locations.Add(Convert.ToString(dtRegionalUserLocations.Rows[i]["Location_Code"] + " - " + dtRegionalUserLocations.Rows[i]["Location_Name"])); // } // SessionManager.CurrentUser.RegionalLocations = locations; //} //else //{ // SessionManager.CurrentUser.IsRegionalUser = false; // SessionManager.CurrentUser.RegionalLocations = null; //} //Response.Redirect("/myHomePage.aspx"); objloginrecordproperty = new Login_Record_Property(); objloginrecordproperty.Employee_ID = Convert.ToInt32(userDT.Rows[0]["EmployeeID"]); objloginrecordproperty.Login_Time = DateTime.Now; objloginrecordproperty.Location_Name = ""; objloginrecordproperty.latitude = objUserPropertyNew.Latitude; objloginrecordproperty.longitude = objUserPropertyNew.Longitude; objloginrecordbll = new Login_Records_BLL(objloginrecordproperty); var flag = objloginrecordbll.Insert(); FormsAuthentication.SetAuthCookie(objUserPropertyNew.UserName, objUserPropertyNew.RemeberMe); //return RedirectToAction("Profile"); return(Json(new { success = true, Login = true, statuscode = 200, msg = "Login Successfull" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { //Trace.Write("Testtt"); //Trace.Write(ex.Message); //lblError.Visible = true; //lblError.Text = "Invalid Username Or Password"; return(Json(new { success = false, Login = false, statuscode = 500, msg = "err" + ex }, JsonRequestBehavior.AllowGet)); } } }