public async Task <JsonResult> Authenticate() { var result = await TryAuthenticateFromHttpContext(_communityService, _notificationService); if (result.Status == LiveConnectSessionStatus.Connected) { _baseModel.User = SessionWrapper.Get <ProfileDetails>("ProfileDetails"); return(Json(new { Status = result.Status.ToString(), Session = new { result.Session.AccessToken, result.Session.AuthenticationToken, Expires = result.Session.Expires.ToLocalTime().ToString(), result.Session.RefreshToken, result.Session.Scopes, User = SessionWrapper.Get <string>("CurrentUserProfileName") }, }, JsonRequestBehavior.AllowGet)); } var svc = new LiveIdAuth(); var url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); SessionWrapper.Clear(); return(Json(new { Status = result.Status.ToString(), S = url }, JsonRequestBehavior.AllowGet)); }
public async Task<JsonResult> Authenticate() { var profile = await TryAuthenticateFromHttpContext(); if (profile != null) { _baseModel.User = profile; return Json(new { Status = "Connected", Session = new { User = SessionWrapper.Get<string>("CurrentUserProfileName") }, }, JsonRequestBehavior.AllowGet); } var svc = new LiveIdAuth(); var url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); SessionWrapper.Clear(); return Json(new { Status = "unknown", S = url }, JsonRequestBehavior.AllowGet); }
public bool CheckUserSavedSession(int userId) { bool result = false; var userSessionData = _iUserService.GetUserSessionDetail(userId); if (userSessionData != null) { SessionWrapper.Set(AppConstant.SchoolId, userSessionData.SchoolId); SessionWrapper.Set(AppConstant.AcademicId, userSessionData.AcademicId); var SchoolName = _iDataService.SchoolAll().Where(x => x.ID == userSessionData.SchoolId).FirstOrDefault(); if (SchoolName != null) { SessionWrapper.Set(AppConstant.SchoolName, SchoolName.Name); } var AcademicName = _iDataService.AcademicYear(userSessionData.SchoolId).Where(x => x.ID == userSessionData.AcademicId).FirstOrDefault(); if (AcademicName != null) { SessionWrapper.Set(AppConstant.AcademicName, AcademicName.Name); } SessionWrapper.Set(AppConstant.SchoolId, userSessionData.SchoolId); SessionWrapper.Set(AppConstant.AcademicId, userSessionData.AcademicId); var menu = _iRoleService.GetRoleAndMenuDetailsByRoleId(SessionWrapper.Get <int>(AppConstant.RoleId)); TempData["Menu"] = menu; result = true; } return(result); }
public async Task <JsonResult> GetAllTypes() { if (CurrentUserId == 0) { await TryAuthenticateFromHttpContext(); } var highlightTypes = (from HighlightType t in Enum.GetValues(typeof(HighlightType)) select t.ToString()).ToList(); var entityTypes = (from EntityType t in Enum.GetValues(typeof(EntityType)) select t.ToString()).ToList(); var categoryTypes = (from CategoryType t in Enum.GetValues(typeof(CategoryType)) select t.ToString()).ToList(); var contentTypes = (from ContentTypes t in Enum.GetValues(typeof(ContentTypes)) select t.ToString()).ToList(); var searchTypes = (from SearchSortBy t in Enum.GetValues(typeof(SearchSortBy)) select t.ToString()).ToList(); var admin = false; if (CurrentUserId != 0) { var profileDetails = SessionWrapper.Get <ProfileDetails>("ProfileDetails"); admin = profileDetails.UserType == UserTypes.SiteAdmin; } return(new JsonResult { Data = new { highlightValues = highlightTypes, entityValues = entityTypes, categoryValues = categoryTypes, contentValues = contentTypes, searchValues = searchTypes, currentUserId = CurrentUserId, isAdmin = admin }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
protected void Page_LoadComplete(object sender, EventArgs e) { if (!String.IsNullOrEmpty(GUID)) { SQLDatabase sql = new SQLDatabase(); sql.CommandTimeout = 120; SQLParamList sqlParams = new SQLParamList(); UserInfo ui = SessionWrapper.Get <UserInfo>("UserInfo"); sqlParams.Add("@GUID", GUID) .Add("@UpdateLastViewedTime", !(ui != null || RequestVars.Get <string>("a", null) != null)); DataSet ds = sql.ExecStoredProcedureDataSet("[spFeedback_GetGuestItem]", sqlParams); if (!sql.HasError) { Data = ds; GCCPropertyShortCode sc = (GCCPropertyShortCode)Conversion.StringToInt(ds.Tables[0].Rows[0]["PropertyID"].ToString(), 1); Master.ForceSpecificProperty = sc; MessageTimeline.PropertyShortCode = sc; MessageTimeline.Messages = ds.Tables[1]; int feedbackStatus = Conversion.StringToInt(ds.Tables[0].Rows[0]["FeedbackStatusID"].ToString()); MessageTimeline.HideReplyBox = ui != null || RequestVars.Get <string>("a", null) != null; Title = PropertyTools.GetCasinoName((int)sc) + " Feedback"; } } }
public static void SaveRadioButtons(params SurveyRadioButton[] buttonsInGroup) { bool foundNew = false; foreach (SurveyRadioButton rad in buttonsInGroup) { if (rad.Checked && !SessionWrapper.Get(rad.SessionKey, new SurveySessionControl <bool>(false)).Value) { foundNew = true; } } foreach (SurveyRadioButton rad in buttonsInGroup) { if (rad.Checked) { if (!SessionWrapper.Get(rad.SessionKey, new SurveySessionControl <bool>(false)).Value || !foundNew) { //If it wasn't checked already or it's the same one as before, check it. SessionWrapper.Add(rad.SessionKey, new SurveySessionControl <bool>(true)); rad.Checked = true; } else if (foundNew) { //Uncheck other radio buttons that may have been flagged as checked if we know that we've already found a checked one. SessionWrapper.Add(rad.SessionKey, new SurveySessionControl <bool>(false)); rad.Checked = false; } } else { SessionWrapper.Add(rad.SessionKey, new SurveySessionControl <bool>(false)); rad.Checked = false; } } }
/// <summary> /// Checks if the user is site admin or not /// No DB check as Most of the users are not site admins and will have session value as false /// </summary> protected static void CheckIfSiteAdmin() { if (!SessionWrapper.Get("IsSiteAdmin", false)) { throw new HttpException(401, Resources.NoPermissionAdminScreenMessage); } }
public async Task <JsonResult> New() { if (CurrentUserId == 0) { await TryAuthenticateFromHttpContext(_communityService, _notificationService); } var result = SessionWrapper.Get <LiveLoginResult>("LiveConnectResult"); if (result != null && result.Status == LiveConnectSessionStatus.Connected) { var profileDetails = SessionWrapper.Get <ProfileDetails>("ProfileDetails"); // While creating the user, IsSubscribed to be true always. profileDetails.IsSubscribed = true; // When creating the user, by default the user type will be of regular. profileDetails.UserType = UserTypes.Regular; profileDetails.ID = ProfileService.CreateProfile(profileDetails); SessionWrapper.Set("CurrentUserID", profileDetails.ID); CreateDefaultUserCommunity(profileDetails.ID); // Send New user notification. _notificationService.NotifyNewEntityRequest(profileDetails, HttpContext.Request.Url.GetServerLink()); return(new JsonResult { Data = profileDetails }); } return(Json("error: User not logged in")); }
public async Task <ActionResult> ViewResult(string group, string page) { try { if (group.ToLower() == "community" && page.ToLower() == "profile" && _baseModel.User == null) { await TryAuthenticateFromHttpContext(); if (CurrentUserId != 0) { _baseModel.User = SessionWrapper.Get <ProfileDetails>("ProfileDetails"); return(await GetViewOrRedirect(group, page, _baseModel)); } return(Redirect("/Community")); } ViewBag.page = page; ViewBag.group = group; ViewBag.CurrentUserId = CurrentUserId; return(await GetViewOrRedirect(group, page, _baseModel)); } catch (Exception e) { _logger.LogError(e, "ViewResult: error in dispatch"); return(View("~/Views/Support/Error.cshtml", _baseModel)); } }
public ActionResult Index(int?page) { if (TempData["Message"] != null) { ViewBag.Message = TempData["Message"]; } OrderSearchViewModel model = new OrderSearchViewModel(); var res = HttpContext.User.Identity.Name; var user = _iUserService.GetAll().Where(m => m.UserEmailAddress == res).FirstOrDefault(); AssignSessionVariables(user); try { model.TotalCount = _iOrderService.GetAll(SessionWrapper.Get <int>(AppConstant.UserId), SessionWrapper.Get <int>(AppConstant.RoleId)).Count(); var pager = new Pager(model.TotalCount, page); model.lstOrders = _iOrderService.GetAll(SessionWrapper.Get <int>(AppConstant.UserId), SessionWrapper.Get <int>(AppConstant.RoleId)); model.status.FreshOrders = model.lstOrders.Where(m => m.CurrentStatus == 1).Count(); model.status.InProgress = model.lstOrders.Where(m => m.CurrentStatus == 2).Count(); model.status.OutForDelivery = model.lstOrders.Where(m => m.CurrentStatus == 3).Count(); model.status.Delivered = model.lstOrders.Where(m => m.CurrentStatus == 4).Count(); model.status.Returned = model.lstOrders.Where(m => m.CurrentStatus == 5).Count(); model.status.totalOrders = model.TotalCount; model.lstOrders = model.lstOrders .Skip((pager.CurrentPage - 1) * pager.PageSize).Take(pager.PageSize).ToList(); model.Pager = pager; return(View(model)); } catch (Exception ex) { ViewBag.Message = helper.GenerateMessage(" " + ex.Message, MessageType.Error); } return(View(model)); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!String.IsNullOrEmpty(SessionKey) && SelectedIndex == -1) { SelectedIndex = SessionWrapper.Get(SessionKey, -1); } }
public ProcResult Add(OrderViewModel model) { RemarksViewModel remarks = new RemarksViewModel(); remarks.EID = SessionWrapper.Get <int>(AppConstant.UserId); remarks.EIDDate = DateTime.Now; remarks.Comment = model.Comment; return(_iOrderRepository.AddOrder(Mapper.Map <Order>(model), Mapper.Map <Remark>(remarks))); }
public ActionResult SetModuleId(int id) { var menu = _iRoleService.GetRoleAndMenuDetailsByRoleId(SessionWrapper.Get <int>(AppConstant.RoleId)); menu.lstModuleList = menu.lstModuleList.Where(x => x.ModuleID == id).ToList(); TempData["Menu"] = menu; SessionWrapper.Set(AppConstant.ModuleId, id); return(RedirectToAction("Index", new { controller = "DashBoard", area = "Home" })); }
protected static bool ValidateAuthentication(bool throwWebFaultException, out ProfileDetails profileDetails) { LiveLoginResult result = SessionWrapper.Get <LiveLoginResult>("LiveConnectResult"); if (result != null && result.Status == LiveConnectSessionStatus.Connected) { profileDetails = SessionWrapper.Get <ProfileDetails>("ProfileDetails"); return(true); } profileDetails = new ProfileDetails(); return(false); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!String.IsNullOrEmpty(SessionKey + "_BeginDate") && String.IsNullOrEmpty(hdnBegin.Value)) { BeginDate = SessionWrapper.Get <DateTime?>(SessionKey + "_BeginDate", null); } if (!String.IsNullOrEmpty(SessionKey + "_EndDate") && String.IsNullOrEmpty(hdnEnd.Value)) { EndDate = SessionWrapper.Get <DateTime?>(SessionKey + "_EndDate", null); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!String.IsNullOrEmpty(SessionKey) && !Checked) { var sVal = SessionWrapper.Get <SurveySessionControl <bool> >(SessionKey, null); if (sVal != null) { Checked = sVal.Value; } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!String.IsNullOrEmpty(SessionKey) && SelectedValue == -1) { var sVal = SessionWrapper.Get <SurveySessionControl <int> >(SessionKey, null); if (sVal != null) { SelectedValue = sVal.Value; } } }
public ActionResult AddOrder(OrderViewModel model) { model.Date = DateTime.Now.Date; model.AgentName = SessionWrapper.Get <string>(AppConstant.UserName); if (SessionWrapper.Get <int>(AppConstant.RoleId) == 2) { model.CurrentStatus = 1; ModelState.Remove("CurrentStatus"); } if (ModelState.IsValid) { ProcResult rMaster = new ProcResult(); try { if (model.OrderId == 0) { model.EID = SessionWrapper.Get <int>(AppConstant.UserId); model.EIDDate = DateTime.Now; if (model.Comment == null) { model.Comment = "Order Created By: " + SessionWrapper.Get <string>(AppConstant.UserName); } rMaster = _iOrderService.Add(model); } else { model.UID = SessionWrapper.Get <int>(AppConstant.UserId); model.UIDDate = DateTime.Now; rMaster = _iOrderService.Update(model); } if (rMaster.ErrorID == 0) { TempData["Message"] = helper.GenerateMessage(rMaster.strResult, MessageType.Success); } else { TempData["Message"] = helper.GenerateMessage(rMaster.strResult, MessageType.Error); } } catch (Exception ex) { TempData["Message"] = helper.GenerateMessage(ex.Message, MessageType.Error); } return(RedirectToAction("Index")); } else { model.lstOrderStatus = _iDataService.GetOrdersStatus(); model.lstDistricts = _iDataService.GetDistricts(); model.lstProducts = _iDataService.GetProducts(); return(View("NewOrder", model)); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (!String.IsNullOrEmpty(SessionKey) && String.IsNullOrEmpty(Text)) { string ret = SessionWrapper.Get(SessionKey, String.Empty); if (!String.IsNullOrEmpty(ret)) { Text = ret; } } }
public ActionResult Logout() { var svc = SessionWrapper.Get <LiveIdAuth>("LiveAuthSvc"); var url = "/"; if (svc != null) { url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); } SessionWrapper.Clear(); return(Redirect(url)); //View("~/Views/Index.cshtml", baseModel); }
public ActionResult Logout() { _iAccountService.UpdateLoginSatus(SessionWrapper.Get <int>(AppConstant.UserId), 0); Session.Clear(); Session.Abandon(); var ctx = Request.GetOwinContext(); var authenticationManager = ctx.Authentication; // Sign Out. authenticationManager.SignOut(); return(RedirectToAction("Index", "Account")); }
public OrderViewModel GetById(int id, int UserId, int roleId) { OrderViewModel model = new OrderViewModel(); var orderstatus = _iDataService.GetOrdersStatus(); model.lstOrderStatus = orderstatus; var districts = _iDataService.GetDistricts(); model.lstDistricts = districts; var products = _iDataService.GetProducts(); model.lstProducts = products; model.Date = DateTime.Now.Date; model.AgentName = SessionWrapper.Get <string>(AppConstant.UserName); if (roleId == 1) { if (id > 0) { model = Mapper.Map <OrderViewModel>(_iOrderRepository.GetOrderById(id)); model.Remarks = _iRemarksRepository.GetRemarkById(model.OrderId).UseAsDataSource(Mapper.Configuration).For <RemarksViewModel>().ToList(); var s = orderstatus.Where(m => m.ID == model.CurrentStatus).FirstOrDefault(); model.CurrentStatusValue = s.Name; } model.lstOrderStatus = orderstatus; model.lstDistricts = districts; model.lstProducts = products; } else { if (id > 0) { model = Mapper.Map <OrderViewModel>(_iOrderRepository.GetOrderById(id, UserId)); if (model != null) { model.Remarks = _iRemarksRepository.GetRemarkById(model.OrderId).UseAsDataSource(Mapper.Configuration).For <RemarksViewModel>().ToList(); var s = orderstatus.Where(m => m.ID == model.CurrentStatus).FirstOrDefault(); model.CurrentStatusValue = s.Name; model.lstOrderStatus = orderstatus; model.lstDistricts = districts; model.lstProducts = products; } else { OrderViewModel obj = new OrderViewModel(); obj.Message = "Not AUthorized"; return(obj); } } } return(model); }
private void AssignSessionVariables(UserViewModel user, List <RoleDetails> lstRole) { SessionWrapper.Set(AppConstant.UserId, user.UserId); SessionWrapper.Set(AppConstant.UserEmailID, user.UserEmailAddress); SessionWrapper.Set(AppConstant.UserName, user.UserName); SessionWrapper.Set(AppConstant.UserType, user.UserType); SessionWrapper.Set(AppConstant.LastLoginDateTime, user.LastLogin); var roleId = lstRole.FirstOrDefault().RoleId; var roleName = lstRole.FirstOrDefault().RoleName; SessionWrapper.Set(AppConstant.RoleId, roleId); SessionWrapper.Set(AppConstant.RoleName, roleName); if (user.UserTypeID == (int)UserType.Student) { // Assign SchoolId and Academic Year. SessionWrapper.Set(AppConstant.SchoolId, user.SchoolId); SessionWrapper.Set(AppConstant.StudentId, user.EmployeeID); var SchoolName = _iDataService.SchoolAll().Where(x => x.ID == user.SchoolId).FirstOrDefault(); if (SchoolName != null) { SessionWrapper.Set(AppConstant.SchoolName, SchoolName.Name); } List <MyStudentViewModel> lststudentData = _iStudentService.GetStudentDetailByStudentId(user.EmployeeID == null ? 0 : user.EmployeeID.Value, user.SchoolId); int academicYearId = lststudentData.Max(x => x.AcademicID.Value); int StudentDetailId = lststudentData.Where(x => x.AcademicID == academicYearId).FirstOrDefault().StudentDetailID; SessionWrapper.Set(AppConstant.StudentIdDetailId, StudentDetailId); int[] academicYearList = lststudentData.Select(x => x.AcademicID.Value).ToArray(); var AcademicName = _iDataService.AcademicYear(user.SchoolId).Where(x => x.ID == academicYearId).FirstOrDefault(); if (AcademicName != null) { SessionWrapper.Set(AppConstant.AcademicName, AcademicName.Name); } SessionWrapper.Set(AppConstant.AcademicId, academicYearId); SessionWrapper.Set(AppConstant.AcademicYearList, (from t in _iDataService.AcademicYear(user.SchoolId).Where(x => academicYearList.Contains(x.ID)) select new DropDownEntry { ID = t.ID, Name = t.Name }).ToList()); int classId = lststudentData.Where(x => x.AcademicID == academicYearId).FirstOrDefault().ClassID; int sectionId = lststudentData.Where(x => x.AcademicID == academicYearId).FirstOrDefault().SectionID; SessionWrapper.Set(AppConstant.ClassId, classId); SessionWrapper.Set(AppConstant.SectionId, sectionId); var menu = _iRoleService.GetRoleAndMenuDetailsByRoleId(SessionWrapper.Get <int>(AppConstant.RoleId)); TempData["Menu"] = menu; } }
public ActionResult Status(int id) { OrderViewModel order = new OrderViewModel(); try { order = _iOrderService.GetStatusById(id, SessionWrapper.Get <int>(AppConstant.UserId), SessionWrapper.Get <int>(AppConstant.RoleId)); } catch (Exception ex) { order.Message = helper.GenerateMessage(" " + ex.Message, MessageType.Error); } return(View(order)); }
protected override void OnInit(EventArgs e) { //Check HTTPS first. BasePage.VerifyHTTPS(Request, Response); //Attach the user to the master page try { User = ((AuthenticatedPage <UserInfo>) this.Page).User; } catch { User = SessionWrapper.Get <UserInfo>("UserInfo", null); } base.OnInit(e); }
protected async Task <ProfileDetails> TryAuthenticateFromHttpContext() { if (SessionWrapper.Get <ProfileDetails>("ProfileDetails") != null) { return(SessionWrapper.Get <ProfileDetails>("ProfileDetails")); } var svc = new LiveIdAuth(); var result = await svc.Authenticate(); string userId = null; if (result.Status != LiveConnectSessionStatus.Connected) { var resultstring = await svc.RefreshTokens(); if (string.IsNullOrEmpty(resultstring)) { return(null); } var tokens = new { access_token = "", refresh_token = "" }; var json = JsonConvert.DeserializeAnonymousType(resultstring, tokens); userId = await svc.GetUserId(tokens.access_token); if (string.IsNullOrEmpty(userId)) { return(null); } return(await InitUserProfile(userId, json.access_token)); } var client = new LiveConnectClient(result.Session); dynamic jsonResult = null; var getResult = await client.GetAsync("me"); jsonResult = getResult.Result as dynamic; foreach (KeyValuePair <string, object> item in jsonResult) { if (item.Key.ToLower() == "id") { userId = item.Value.ToString(); } } //userId = jsonResult["id"].ToString(); return(await InitUserProfile(userId, result.Session.AccessToken)); }
public ActionResult AdminAddUser(UserViewModel model) { model.ImageUrl = "UserImages/" + "avatar5.png"; ModelState.Remove("lstRoles"); model.lstRoles = _iDataService.GetRoles(); if (ModelState.IsValid) { ProcResult rMaster = new ProcResult(); try { model.EID = SessionWrapper.Get <int>(AppConstant.UserId); if (!string.IsNullOrEmpty(model.UserPassword)) { model.UserPassword = new UtilityHelper().EncrpytPassword(model.UserPassword); } if (model.UserId == 0) { model.Flag = "A"; rMaster = _iUserService.Save(model); } else { rMaster = _iUserService.Save(model); } if (rMaster.ErrorID == 0) { model = new UserViewModel(); model.lstRoles = _iDataService.GetRoles(); TempData["Message"] = helper.GenerateMessage(rMaster.strResult + " Wait for Admin Approval", MessageType.Success); } else { TempData["Message"] = helper.GenerateMessage(rMaster.strResult, MessageType.Error); } } catch (Exception ex) { TempData["Message"] = helper.GenerateMessage(ex.Message, MessageType.Error); } return(RedirectToAction("Index")); } else { return(View("NewUser", model)); } }
// GET: DashBoard/Details/5 public ActionResult AccountFlag(int id, string flag) { ProcResult rMaster = new ProcResult(); UserViewModel model = new UserViewModel(); try { model = _iUserService.GetById(id); model.Flag = flag; model.EID = SessionWrapper.Get <int>(AppConstant.UserId); rMaster = _iUserService.ActivateAndDeActivate(id, model); } catch (Exception ex) { } return(RedirectToAction("Index")); }
public ActionResult ChangeRole(int id, int roleId) { ProcResult rMaster = new ProcResult(); UserViewModel model = new UserViewModel(); try { model = _iUserService.GetById(id); model.RoleId = roleId; model.EID = SessionWrapper.Get <int>(AppConstant.UserId); rMaster = _iUserService.ChangeRole(id, model); } catch (Exception ex) { } return(RedirectToAction("Index")); }
protected void Application_AcquireRequestState(object sender, EventArgs e) { //If the session doesn't exist, culture probably doesn't apply to this request. For example, this will happen when favicon.ico is requested. if (HttpContext.Current.Session == null) { return; } //Figure out the culture of the current request. string cultureName; //See if we have a session variable. If not, check for a cookie from last time. if (!SessionWrapper.Exists("DisplayLanguage")) { //No session, let's check the cookie HttpCookie cook = HttpContext.Current.Request.Cookies["DisplayLanguage"]; if (cook != null && cook.Value.Equals("fr-CA")) { //Found French cookie cultureName = "fr-CA"; } else { //No cookie or cookie not French, default to English-Canada cultureName = "en-CA"; } //Save in session for future requests SessionWrapper.Add("DisplayLanguage", cultureName); } else { //Session value exists, load it cultureName = SessionWrapper.Get("DisplayLanguage", "en-CA"); } //Don't do anything if it's the same culture if (Thread.CurrentThread.CurrentUICulture.Name == cultureName) { return; } //Set the thread culture Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture; }