protected void Page_Init(object sender, EventArgs e) { string strID = Request.QueryString["id"]; long id; string strParentID = Request.QueryString["parent-id"]; long parent_id; if (!long.TryParse(strParentID, out parent_id)) RedirectHash("admin/drugs/companies/list"); Company = new Lib.Data.DrugCompany(parent_id); if (string.IsNullOrEmpty(strID) || !long.TryParse(strID, out id)) { item = new Lib.Data.DrugCompanyUser(); profile = new Lib.Data.UserProfile(); contact = new Lib.Data.Contact(); address = new Lib.Data.Address(); user = new Framework.Security.User(); } else { item = new Lib.Data.DrugCompanyUser(id); profile = item.Profile; user = profile.User; contact = profile.PrimaryContact; address = profile.PrimaryAddress; } }
protected void Page_Init(object sender, EventArgs e) { string strID = Request.QueryString["id"]; long id; if( string.IsNullOrEmpty(strID) || !long.TryParse(strID,out id) ) item = new Lib.Data.UserProfile(); else item = new Lib.Data.UserProfile(id); user = item.User; if (user == null) user = new Framework.Security.User(); contact = item.PrimaryContact; if (contact == null) contact = new Lib.Data.Contact(); Groups = Framework.Security.Group.FindAll(); UserGroups = user.GetGroups(); UserTypes = Lib.Data.UserType.FindAll(); }
protected void Page_Init(object sender, EventArgs e) { long providerUserId = long.Parse(Request.QueryString["provider-user-id"]); long organizationId = long.Parse(Request.QueryString["organization-id"]); Organization = _orgSvc.Get(organizationId); if(providerUserId <= 0) { ProviderUser = new ProviderUser(); UserProfile = new UserProfile(); Contact = new Contact(); Address = new Address(); User = new Framework.Security.User(); } else { ProviderUser = new ProviderUser(providerUserId); UserProfile = ProviderUser.Profile; User = UserProfile.User; Contact = UserProfile.PrimaryContact; Address = UserProfile.PrimaryAddress; } }
public static ReturnObject Delete(HttpContext context, long id) { if( id <= 0 ) return new ReturnObject() { Error = true, Message = "Invalid User." }; var item = new Framework.Security.User( id ); var profile = Data.UserProfile.FindByUser(item); if (profile != null) { var contact = profile.PrimaryContact; if (contact != null) contact.Delete(); profile.Delete(); } item.Delete(); return new ReturnObject() { Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully deleted a user.", title = "User Deleted" } }, Actions = new List<ReturnActionObject>() { new ReturnActionObject() { Ele = "#users-table tr[data-id=\""+id.ToString()+"\"]", Type = "remove" } } }; }
protected void Page_Init(object sender, EventArgs e) { long prescriberProfileId = long.Parse(Request.QueryString["prescriber-profile-id"]); States = State.FindAll(); Specialities = Speciality.FindAll(); PrescriberTypes = PrescriberType.FindAll(); if(prescriberProfileId <= 0) { PrescriberProfile = new PrescriberProfile(); Prescriber = new Lib.Data.Prescriber(); SpecialityId = 0; TypeId = 0; User = new Framework.Security.User(); Account = new Account { ExpiresOn = DateTime.Now }; } else { PrescriberProfile = new PrescriberProfile(prescriberProfileId); Prescriber = PrescriberProfile.Prescriber; SpecialityId = Prescriber.SpecialityID ?? 0; TypeId = PrescriberProfile.PrescriberTypeID ?? 0; UserProfile userProfile = new UserProfile(Prescriber.ProfileID); User = userProfile.User; Account = _accountSvc.GetByUserProfileId(userProfile.ID ?? 0); } }
public static ReturnObject Edit( HttpContext context, long provider_id, long profile_id, string first_name, string last_name, string email, string phone, string street_1, string city, string state, string zip, string npi, string state_id, long issuer, long speciality, long prescriber_type, string username, string password, string confirm_password, string expires_on, string is_enabled, string street_2 = null, string fax = null) { IAccountService accountSvc = ObjectFactory.GetInstance<IAccountService>(); UserProfile userProfile; PrescriberProfile prescriberProfile; Data.Prescriber prescriber; Address address; Contact contact; Account account; Framework.Security.User user; if (profile_id > 0) { prescriberProfile = new PrescriberProfile(profile_id); prescriber = prescriberProfile.Prescriber; userProfile = prescriber.Profile; user = userProfile.User; address = userProfile.PrimaryAddress; contact = userProfile.PrimaryContact; account = accountSvc.GetByUserProfileId(userProfile.ID ?? 0); } else { userProfile = new UserProfile(); userProfile.Created = DateTime.Now; prescriberProfile = new PrescriberProfile(); prescriber = new Data.Prescriber(); contact = new Contact(); user = new Framework.Security.User(); address = new Address(); account = new Account { CreatedAt = DateTime.Now }; } if (!user.ID.HasValue && string.IsNullOrEmpty(password)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = "If you are creating a new prescriber, you must enter a password." }; } if (!string.IsNullOrEmpty(password) ) { if (password != confirm_password) { return new ReturnObject() { Error = true, StatusCode = 200, Message = "The passwords you entered do no match." }; } else { user.PasswordSalt = Framework.Security.Manager.GetRandomSalt(); user.Password = Framework.Security.Hash.GetSHA512(password + user.PasswordSalt); } } user.Username = username; user.Email = email; user.Save(); IList<Framework.Security.Group> userGroups = user.GetGroups(); if(!userGroups.Any(x => x.ID == 2)) user.AddGroup(new Framework.Security.Group(2)); if(!userGroups.Any(x => x.ID == 3)) user.AddGroup(new Framework.Security.Group(3)); contact.Email = email; contact.Phone = phone; contact.FirstName = first_name; contact.LastName = last_name; contact.Save(); DateTime expiresOn; if(!DateTime.TryParse(expires_on, out expiresOn)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = "Invalide expiration date." }; } address.Street1 = street_1; address.Street2 = street_2; address.City = city; address.State = state; address.Zip = zip; address.Country = "United States"; address.Save(); userProfile.UserID = user.ID.Value; userProfile.UserTypeID = 0; userProfile.PrimaryAddressID = address.ID.Value; userProfile.PrimaryContactID = contact.ID.Value; userProfile.IsEcommerce = true; userProfile.Save(); prescriber.ProfileID = userProfile.ID.Value; prescriber.SpecialityID = speciality; prescriber.NpiId = npi; prescriber.StateId = state_id; prescriber.StateIdIssuer = issuer; prescriber.Save(); prescriberProfile.PrescriberID = prescriber.ID; prescriberProfile.ProviderID = provider_id; prescriberProfile.AddressID = address.ID.Value; prescriberProfile.ContactID = contact.ID.Value; prescriberProfile.PrescriberTypeID = prescriber_type; prescriberProfile.PrimaryFacilityID = 0; prescriberProfile.Expires = DateTime.Now.AddYears(1); prescriberProfile.OrganizationId = provider_id; prescriberProfile.Guid = Guid.NewGuid(); prescriberProfile.Save(); account.UserProifleId = userProfile.ID ?? 0; account.ExpiresOn = expiresOn; account.IsEnabled = is_enabled == "yes"; accountSvc.Save(account); return new ReturnObject() { Result = prescriber, Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully saved this Prescriber.", title = "Prescriber Saved" } } }; }
protected void Page_Init(object sender, EventArgs e) { long prescriberProfileId = long.Parse(Request.QueryString["prescriber-profile-id"]); ProviderId = long.Parse(Request.QueryString["provider-id"]); Organization org = _orgSvc.Get(ProviderId); Facilities = org.Facilities; States = State.FindAll(); Specialities = Speciality.FindAll(); PrescriberTypes = PrescriberType.FindAll(); PrescriberProfile = new PrescriberProfile(prescriberProfileId); Prescriber = PrescriberProfile.Prescriber; SpecialityId = Prescriber.SpecialityID ?? 0; TypeId = PrescriberProfile.PrescriberTypeID ?? 0; UserProfile userProfile = new UserProfile(Prescriber.ProfileID); User = userProfile.User; }
public BaseControl() { User = Framework.Security.Manager.GetUser(); }
protected void Page_Init(object sender, EventArgs e) { long providerUserId = long.Parse(Request.QueryString["provider-user-id"]); if(providerUserId <= 0) { ProviderUser = new ProviderUser(); UserProfile = new UserProfile(); Contact = new Contact(); Address = new Lib.Data.Address(); User = new Framework.Security.User(); Account = new Account { ExpiresOn = DateTime.Now }; } else { ProviderUser = new ProviderUser(providerUserId); UserProfile = ProviderUser.Profile; User = UserProfile.User; Contact = UserProfile.PrimaryContact; Address = UserProfile.PrimaryAddress; Account = GetAccountByUserProfile(UserProfile); } }
public static ReturnObject Edit(HttpContext context, string username, string email, long user_type, string contact_prefix, string contact_name, string contact_phone, string contact_suffix = "", string contact_title = "", string contact_fax = "", string password = "", string confirm = "", long id = 0) { if( id == 0 && string.IsNullOrEmpty( password ) ) return new ReturnObject() { Error = true, Message = "A password is required to create a new user." }; Framework.Security.User item = null; Data.UserProfile profile = null; Data.Contact contact = null; if (id > 0) { item = new Framework.Security.User(id); profile = Data.UserProfile.FindByUser(item); contact = profile.PrimaryContact; if( contact == null ) contact = new Data.Contact(); } else { if (Framework.Security.Manager.UserExists(email, username)) return new ReturnObject() { Error = true, Message = "A user with that username / email is already in the system." }; item = new Framework.Security.User(); item.ResetPasswordGuid = Guid.Empty; item.LastLogin = DateTime.Now; profile = new Data.UserProfile(); profile.Created = DateTime.Now; contact = new Data.Contact(); } item.Username = username; item.Email = email; if( !string.IsNullOrEmpty( password ) ) { if( password != confirm ) return new ReturnObject() { Error = true, Message = "Your passwords do not match." }; item.PasswordSalt = Framework.Security.Manager.GetRandomSalt(); item.Password = Framework.Security.Hash.GetSHA512(password+item.PasswordSalt); } var name_parts = contact_name.Split(' '); if (name_parts.Length <= 1) return new ReturnObject() { Error = true, Message = "Please enter the contact's full name." }; item.Save(); string fname = name_parts[0]; string lname = name_parts[name_parts.Length - 1]; for (var i = 1; i < name_parts.Length - 1; i++) fname += " " + name_parts[i]; contact.Prefix = contact_prefix; contact.FirstName = fname; contact.LastName = lname; contact.Postfix = contact_suffix; contact.Title = contact_title; contact.Email = email; contact.Phone = contact_phone; contact.Fax = contact_fax; contact.Save(); profile.UserID = item.ID.Value; if (profile.UserTypeID != user_type) { profile.UserTypeID = user_type; item.ClearGroups(); item.AddGroup(Framework.Security.Group.FindByName("users")); item.AddGroup(Framework.Security.Group.FindByName("admin")); if( user_type == 1 ) item.AddGroup(Framework.Security.Group.FindByName("dev")); } profile.PrimaryContactID = contact.ID; profile.Save(); return new ReturnObject() { Result = item, Redirect = new ReturnRedirectObject() { Hash = "admin/security/users/list" }, Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully saved this user.", title = "User Saved" } } }; }