//used to send logged in user to their directory..... public static void GoHome(string username = null, bool termination = true) { try { if (string.IsNullOrEmpty(username)) { username = HttpContext.Current.User.Identity.Name.Trim(); } Cache = new DefaultCacheProvider(); //cache the user role for future use.... if (!Cache.IsSet(SportyConstants.UserRolesCached)) { using (SportyFYEntities model = new SportyFYEntities()) { //get all the roles from the DB var qry = (from tmp in model.aspnet_Roles select tmp).ToList(); //cached for 24 hour..... Cache.Set(SportyConstants.UserRolesCached, qry, 86400); foreach (var item in qry) { //check logged in user role..... if (Roles.IsUserInRole(username, item.RoleName)) { HttpContext.Current.Response.Redirect("~/Views/Common/Home", termination); } } HttpContext.Current.Session.RemoveAll(); HttpContext.Current.Session.Abandon(); System.Web.Security.FormsAuthentication.SignOut(); System.Web.Security.FormsAuthentication.RedirectToLoginPage(); } } else { var roles = Cache.Get(SportyConstants.UserRolesCached) as List <aspnet_Roles>; foreach (var item in roles) { //check logged in user role..... if (Roles.IsUserInRole(username, item.RoleName)) { HttpContext.Current.Response.Redirect("~/Views/Common/Home", termination); } } HttpContext.Current.Session.RemoveAll(); HttpContext.Current.Session.Abandon(); System.Web.Security.FormsAuthentication.SignOut(); System.Web.Security.FormsAuthentication.RedirectToLoginPage(); } } catch (System.Threading.ThreadAbortException ex) { //don't log this..... //comes due to redirection in between of page execution..... } }
public static List <NewsSubCategoryMaster> getNewsSubCategories(int categoryId) { using (SportyFYEntities model = new SportyFYEntities()) { var data = (from a in model.NewsSubCategoryMasters where a.CategoryId == categoryId && a.IsDel != true select a).ToList(); return(data); } }
public static int SaveNewsTags(Guid newsID, string newsTag, Guid?userid) { using (SportyFYEntities model = new SportyFYEntities()) { model.NewsTags.Add(new NewsTag { NewsId = newsID, TagKeywords = newsTag, Userid = userid }); return(model.SaveChanges()); } }
public static int SaveNews(NewsMaster _NewsMaster) { using (SportyFYEntities model = new SportyFYEntities()) { model.NewsMasters.Add(new NewsMaster { NewsId = _NewsMaster.NewsId, CategoryId = _NewsMaster.CategoryId, SubCategoryId = _NewsMaster.SubCategoryId, NewsTitle = _NewsMaster.NewsTitle, NewsContent = _NewsMaster.NewsContent, NewsAuthor = _NewsMaster.NewsAuthor, NewsCreateDate = _NewsMaster.NewsCreateDate, IsDel = _NewsMaster.IsDel, Userid = _NewsMaster.Userid, NewsDate = _NewsMaster.NewsDate }); return(model.SaveChanges()); } }
protected void LoginSporty_LoginError(object sender, EventArgs e) { System.Web.UI.WebControls.Login log = LoginSporty; MembershipUser userInfo = Membership.GetUser(log.UserName); if (userInfo == null) { log.FailureText = CommonMessages.ShowMsg_Literal("There is no user in the database with the username " + log.UserName + ".", CommonMessages.messageType.ERROR); } else { if (!userInfo.IsApproved) { log.FailureText = CommonMessages.ShowMsg_Literal("Your account has not yet been approved. Please try again later...", CommonMessages.messageType.WARNING); } else if (userInfo.IsLockedOut) { SportyFYEntities model = new SportyFYEntities(); string status = ""; var qry = from a in model.UserMasters where a.UserId == (Guid)userInfo.ProviderUserKey select a; foreach (var t in qry) { status = t.status.ToUpper(); if (status.ToUpper() == "U") { log.FailureText = CommonMessages.ShowMsg_Literal("Your account is temporary locked for security reasons...", CommonMessages.messageType.WARNING); string time = ConfigurationManager.AppSettings["autoUnlockTimeout"]; if (!String.IsNullOrEmpty(time)) { if (userInfo.LastLockoutDate.ToUniversalTime().AddMinutes(Double.Parse(time)) < DateTime.UtcNow) { bool retval = userInfo.UnlockUser(); if (retval) { Membership.UpdateUser(userInfo); } } else { //send mail to unlock it now..... } } } else if (status.ToUpper() == "D") { log.FailureText = CommonMessages.ShowMsg_Literal("Your account has been deleted by the Admin due to some reasons...", CommonMessages.messageType.ERROR); } else if (status.ToUpper() == "L") { log.FailureText = CommonMessages.ShowMsg_Literal("Your account has been locked out by the Admin due to some reasons...", CommonMessages.messageType.ERROR); } else { log.FailureText = CommonMessages.ShowMsg_Literal("Your account details has not been authenticated...", CommonMessages.messageType.ERROR); } } } else { log.FailureText = CommonMessages.ShowMsg_Literal("Username or password not match...", CommonMessages.messageType.ERROR); } } }