public static IList<User> FindByGroup(Group g) { if( g == null || g.ID == null ) return new List<User>(); return FindByGroup(g.ID); }
public static void Send(Data.Notification n, Group g) { var us = User.FindByGroup(g); foreach (var u in us) Send(n, u); }
public static List<DistributionList> GetDistributionLists(User user) { // TODO: Fix this // Right now the distribution lists are hard coded. They should be pulled from the database. // There needs to be a table called GroupDistributionLists that can be used to determine // which distribution lists each group has access to. Group admin = new Group(1); Group prescribers = new Group(3); Group providers = new Group(4); Group dev = new Group(6); List<DistributionList> ret = new List<DistributionList>(); if(user.IsInGroup(providers)) ret.Add(new DistributionList(1)); if(user.IsInGroup(admin) || user.IsInGroup(dev)) { ret.Add(new DistributionList(2)); ret.Add(new DistributionList(3)); } return ret; }
public static ReturnObject Update(HttpContext context, long id, long facility_id, string agree_to_terms, string new_password, string confirm_password, string watched_video, string prescriber_type, long prescriber_speciality, string npi, string first_name, string last_name, string title, string email, string phone, string fax, string street_1, string city, string state, long issuer, string zip, string country, string prefix = null, string postfix = null, string street_2 = null, string state_id = null) { // load the profile we're finishing PrescriberProfile profile = new PrescriberProfile(id); // save the contact Contact contact = new Contact() { Prefix = prefix, FirstName = first_name, LastName = last_name, Postfix = postfix, Email = email, Phone = phone, Fax = fax, Title = title }; contact.Save(); // save the address Address address = new Address() { Street1 = street_1, Street2 = street_2, City = city, State = state, Country = country, Zip = zip }; address.Save(); profile.PrimaryFacilityID = facility_id; // get the prescriber type PrescriberType type = PrescriberType.FindByDisplayName(prescriber_type); if(type != null) profile.PrescriberTypeID = type.ID; profile.Save(); // see if the prescriber is already in the system Lib.Data.Prescriber prescriber = Lib.Data.Prescriber.FindByStateId(issuer, state_id); if(prescriber != null) { // tie the new profile to the existing prescriber profile.PrescriberID = prescriber.ID; profile.Save(); // login the existing user so they don't get bounced to the login page. Framework.Security.Manager.Login(prescriber.Profile.User); return new ReturnObject { Result = null, Redirect = new ReturnRedirectObject { //Hash = "dashboard" Url = "Default.aspx#dashboard" }, Growl = new ReturnGrowlObject { Type = "default", Vars = new ReturnGrowlVarsObject { text = "The profile has been attached to your account.", title = "Profile Updated" } } }; } // create the new prescriber String error; User user = Framework.Security.Manager.CreateUser(contact.FirstName.Substring(0,1)+contact.LastName, new_password, email, out error); user.Save(); Group g1 = new Group(2); Group g2 = new Group(3); user.AddGroup(g1); user.AddGroup(g2); UserProfile userProfile = new UserProfile() { PrimaryAddressID = address.ID, PrimaryContactID = contact.ID, Created = DateTime.Now, UserID = user.ID ?? 0, UserTypeID = 3 }; userProfile.Save(); prescriber = new Data.Prescriber { NpiId = npi, StateId = state_id, StateIdIssuer = issuer, ProfileID = userProfile.ID, SpecialityID = prescriber_speciality == 0 ? (long?)null : prescriber_speciality }; prescriber.Save(); // set the prescriber id profile.PrescriberID = prescriber.ID; profile.Save(); // setup the default user peferences UserPreferences prefs = new UserPreferences { UserId = user.ID ?? 0, EmailNotifications = true }; prefs.Save(); Framework.Security.Manager.Login(user); //prescriber. return Success( "Profile Updated", "Your profile has been updated.", null, "Locked.aspx#prescriber/wizards/etasu-selections"); }
public static void Send(Data.Notification n, Group g, string template = null) { var us = User.FindByGroup(g); foreach (var u in us) Send(n, u, template); }
public static List<DistributionList> GetDistributionLists(User user) { // TODO: Fix this // Right now the distribution lists are hard coded. They should be pulled from the database. // There needs to be a table called GroupDistributionLists that can be used to determine // which distribution lists each group has access to. User u = Framework.Security.Manager.GetUser(); UserProfile profile = UserProfile.FindByUser(u); Group admin = new Group(1); Group prescribers = new Group(3); Group providers = new Group(4); Group dev = new Group(6); List<DistributionList> ret = new List<DistributionList>(); // first setup the system default lists if(user.IsInGroup(providers)) { ret.Add(new DistributionList(1)); } if(user.IsInGroup(admin) || user.IsInGroup(dev)) { ret.Add(new DistributionList(2)); ret.Add(new DistributionList(3)); } // now add any user created distribution lists ret.AddRange(DistributionList.FindByUserProfile(profile)); return ret; }
public void AddGroup(Group g) { var tbl = Table.Get(Config.Manager.Framework.Security.Authentication.Connection, "UserGroups"); var data = new Dictionary<string, object>(); data.Add("UserID", this.ID.Value); data.Add("GroupID", g.ID.Value); tbl.Insert(data); }
public bool IsInGroup(Group g) { var db = Database.Get(Config.Manager.Framework.Security.Authorization.Connection); string sql = "SELECT COUNT(1) FROM " + db.Delim("UserGroups", DelimType.Table) + " WHERE " + db.Delim("UserID", DelimType.Column) + " = @uid AND " + db.Delim("GroupID", DelimType.Column) + " = @gid"; var ps = new List<Parameter>(); ps.Add(new Parameter("uid", this.ID.Value)); ps.Add(new Parameter("gid", g.ID.Value)); int num = db.ExecuteScalar<int>(sql, ps.ToArray()); return (num >= 1); }