public static void CreateDefaultSchema() { var db = new Data.SecurityEntities(); var item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "common"); if (item == null) { item = new Data.SchemaVersion(); item.Feature = "common"; item.CompatibleSchemaVersion = "1"; item.IsCurrentVersion = true; db.SchemaVersions.AddObject(item); db.SaveChanges(); } item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "membership"); if (item == null) { item = new Data.SchemaVersion(); item.Feature = "membership"; item.CompatibleSchemaVersion = "1"; item.IsCurrentVersion = true; db.SchemaVersions.AddObject(item); db.SaveChanges(); } item = db.SchemaVersions.FirstOrDefault(x => x.Feature == "role manager"); if (item == null) { item = new Data.SchemaVersion(); item.Feature = "role manager"; item.CompatibleSchemaVersion = "1"; item.IsCurrentVersion = true; db.SchemaVersions.AddObject(item); db.SaveChanges(); } }
public static void UpdateRole(string roleName, string description) { var db = new Data.SecurityEntities(); var role = db.Roles.FirstOrDefault(x => x.Application.ApplicationName == System.Web.Security.Roles.ApplicationName && x.RoleName == roleName); if (role != null) role.Description = description; db.SaveChanges(); }
public static Role GetRole(string roleName, SecurityEntities db) { var query = from row in db.Roles where row.LoweredRoleName == roleName.ToLower() && row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName select row; return query.FirstOrDefault(); }
public static Role GetRole(Guid roleId, SecurityEntities db) { var query = from row in db.Roles where row.RoleId == roleId && row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName select row; return query.FirstOrDefault(); }
public static Role GetRole(Guid roleId, SecurityEntities db) { var query = from row in db.Roles where row.RoleId == roleId && row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName select row; return(query.FirstOrDefault()); }
public static Role GetRole(string roleName, SecurityEntities db) { var query = from row in db.Roles where row.LoweredRoleName == roleName.ToLower() && row.Application.ApplicationName == System.Web.Security.Roles.ApplicationName select row; return(query.FirstOrDefault()); }
public static void UpdateRole(string roleName, string description) { var db = new Data.SecurityEntities(); var role = db.Roles.FirstOrDefault(x => x.Application.ApplicationName == System.Web.Security.Roles.ApplicationName && x.RoleName == roleName); if (role != null) { role.Description = description; } db.SaveChanges(); }
public void CreateRole(string roleName, string description, Guid roleId) { var db = new SecurityEntities(); var role = new Role(); role.ApplicationId = ApplicationId; role.RoleName = roleName; role.RoleId = roleId; role.Description = description; role.LoweredRoleName = roleName.ToLower(); db.Roles.AddObject(role); db.SaveChanges(); }
public static void SendPasswordResetKey(User user, string subject, string body) { var db = new SecurityEntities(); var userId = user.UserId; var m = db.Memberships.FirstOrDefault(x => x.UserId == userId); var resetKey = m.GetPasswordResetToken(); var resetUrl = JocysCom.ClassLibrary.Security.Helper.GetUrl(resetKey); var u = System.Web.HttpContext.Current.Request.Url; subject = subject.Replace("{Host}", u.Host); body = JocysCom.ClassLibrary.Text.Helper.Replace(body, user, false); body = body.Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl); JocysCom.ClassLibrary.Runtime.LogHelper.Current.SendMail(m.Email, subject, body, true); }
public static void SendPasswordResetKey(User user, string subject, string body) { var db = new SecurityEntities(); var userId = user.UserId; var m = db.Memberships.FirstOrDefault(x => x.UserId == userId); var resetKey = m.GetPasswordResetToken(); var resetUrl = JocysCom.ClassLibrary.Security.Helper.GetUrl(PasswordResetKey, resetKey); var u = System.Web.HttpContext.Current.Request.Url; subject = subject.Replace("{Host}", u.Host); body = JocysCom.ClassLibrary.Text.Helper.Replace(body, user, false); body = body.Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl); var helper = JocysCom.ClassLibrary.Runtime.LogHelper.Current; helper.SendMailFrom(helper.Smtp.SmtpFrom, m.Email, "", "", subject, body, true); }
public static void SendPasswordResetKey(User user, string subject, string body) { var db = new SecurityEntities(); var userId = user.UserId; var m = db.Memberships.FirstOrDefault(x => x.UserId == userId); var resetKey = m.GetPasswordResetToken(); var resetUrl = JocysCom.ClassLibrary.Security.Helper.GetUrl(resetKey); var u = System.Web.HttpContext.Current.Request.Url; subject = subject.Replace("{Host}", u.Host); body = JocysCom.ClassLibrary.Text.Helper.Replace(body, user, false); body = body.Replace("{Host}", u.Host).Replace("{ResetKey}", resetUrl); // utilities.Current.SendMail(user.email_to, "", "", subject, body, Nothing) //Engine.Mail.Current.Send(user.Membership.Email, user.FullName, subject, body, JocysCom.ClassLibrary.Mail.MailTextType.Plain); }
public static void CreateDefaultApplication() { var db = new Data.SecurityEntities(); var app = db.Applications.FirstOrDefault(x => x.LoweredApplicationName == "/"); if (app == null) { app = new Data.Application(); app.ApplicationName = "/"; app.LoweredApplicationName = "/"; app.ApplicationId = new Guid("5985BB89-8015-42E3-9FE1-D7F9FD914EEC"); app.Description = "Default Application"; db.Applications.AddObject(app); db.SaveChanges(); } }