public static ReturnObject Delete(HttpContext context, long id) { if (id <= 0) return new ReturnObject() { Error = true, Message = "Invalid Provider." }; var item = new Lib.Data.ProviderUser(id); item.Delete(); return new ReturnObject() { Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully deleted a provider user.", title = "Provider User deleted" } }, Actions = new List<ReturnActionObject>() { new ReturnActionObject() { Ele = "#users-table tr[data-id=\""+id.ToString()+"\"]", Type = "remove" } } }; }
public static IList<ProviderFacility> FindAllByProviderUser(ProviderUser user) { if (user == null || user.ID == null) return new List<ProviderFacility>(); return FindAllByProviderUser(user.ID.Value); }
protected void Page_Init(object sender, EventArgs e) { RequireRole( "view_provider" ); string strID = Request.QueryString["id"]; long id; if( string.IsNullOrEmpty( strID ) || !long.TryParse( strID, out id ) ) RedirectHash( "provider/prescribers/list", true, "Invalid Prescriber" ); else Prescriber = new Prescriber( id ); Provider = Lib.Systems.Security.GetCurrentProvider(); ProviderUser = ProviderUser.FindByProvider(Provider.ID.Value).First(); PrescriberProfile = PrescriberProfile.FindByPrescriberAndProvider(Prescriber, ProviderUser.OrganizationID); ProviderFacilities = ProviderFacility.FindByProvider(Provider); States = State.FindAll(); Specialities = Speciality.FindAll(); SpecialityId = Prescriber.SpecialityID ?? 0; PrescriberTypes = PrescriberType.FindAll(); TypeId = PrescriberProfile.PrescriberTypeID ?? 0; if(PrescriberProfile != null) { PrescriberFacilities = PrescriberProfile.GetFacilities(); Drugs = Lib.Systems.Lists.GetUsersDrugs(PrescriberProfile.ID ?? 0); } else RedirectHash( "provider/prescribers/list", true, "Invalid Prescriber" ); }
public static Provider FindByUser(ProviderUser o) { if (o == null || !o.ID.HasValue) return null; return o.Provider; }
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); } }
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 Edit(HttpContext context, long provider_user_id, long organization_id, long facility_id, string user_type, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string street_2 = null, string phone = null) { Lib.Data.Provider provider; Lib.Data.ProviderUser providerUser; UserProfile userProfile; Contact contact; Address address; Framework.Security.User user; if (provider_user_id > 0) { providerUser = new Lib.Data.ProviderUser(provider_user_id); provider = providerUser.Provider; userProfile = providerUser.Profile; user = userProfile.User; contact = userProfile.PrimaryContact; address = userProfile.PrimaryAddress; user.Username = username; user.Save(); Framework.Security.Manager.SetPassword(user, password); } else { provider = new Lib.Data.Provider(); providerUser = new Lib.Data.ProviderUser(); userProfile = new Data.UserProfile(); userProfile.Created = DateTime.Now; contact = new Data.Contact(); address = new Data.Address(); string error = ""; user = Framework.Security.Manager.CreateUser(username, password, email, out error); user.AddGroup(Framework.Security.Group.FindByName("users")); user.AddGroup(Framework.Security.Group.FindByName("providers")); if (!string.IsNullOrEmpty(error)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = error }; } } if (user_type != "technical" && user_type != "administrative") { return new ReturnObject() { Error = true, StatusCode = 200, Message = "Invalid user type." }; } address.Street1 = street; address.Street2 = street_2; address.City = city; address.State = state; address.Zip = zip; address.Country = "United States"; address.Save(); contact.Email = email; contact.FirstName = first_name; contact.LastName = last_name; contact.Phone = phone; contact.Save(); provider.AddressID = address.ID; provider.PrimaryContactID = contact.ID; provider.Created = DateTime.Now; provider.FacilitySize = String.Empty; provider.Name = string.Empty; provider.Save(); var ut = Lib.Data.UserType.FindByName("provider"); userProfile.UserTypeID = ut.ID.Value; userProfile.UserID = user.ID.Value; userProfile.PrimaryAddressID = address.ID.Value; userProfile.PrimaryContactID = contact.ID.Value; userProfile.Save(); providerUser.ProfileID = userProfile.ID.Value; providerUser.ProviderID = provider.ID.Value; providerUser.OrganizationID = organization_id; providerUser.ProviderUserType = user_type; providerUser.PrimaryFacilityID = facility_id; providerUser.Save(); return new ReturnObject() { Result = providerUser, Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully saved this provider user.", title = "Provider User Saved" } } }; }
protected void Page_Init(object sender, EventArgs e) { _providerUser = ProviderUser.FindByProfile(UserProfile.FindByUser(Framework.Security.Manager.GetUser())); _provider = Provider.FindByUser(_providerUser); Prescribers = _provider.GetPrescribers(); BuildDistributionListArray(DistributionList.FindByUserProfile(UserProfile.FindByUser(Framework.Security.Manager.GetUser()))); }
public static ReturnObject EditProvider(HttpContext context, long provider_user_id, string username, string password, string email, string first_name, string last_name, string street, string city, string state, string zip, string expires_on, string is_enabled, string street_2 = null, string phone = null) { IAccountService accountSvc = ObjectFactory.GetInstance<IAccountService>(); Lib.Data.Provider provider; Lib.Data.ProviderUser providerUser; UserProfile userProfile; Contact contact; Address address; Account account; Framework.Security.User user; if (provider_user_id > 0) { providerUser = new Lib.Data.ProviderUser(provider_user_id); provider = providerUser.Provider; userProfile = providerUser.Profile; user = userProfile.User; contact = userProfile.PrimaryContact; address = userProfile.PrimaryAddress; account = accountSvc.GetByUserProfileId(userProfile.ID ?? 0); user.Username = username; user.Save(); Framework.Security.Manager.SetPassword(user, password); } else { provider = new Lib.Data.Provider(); providerUser = new Lib.Data.ProviderUser(); userProfile = new Data.UserProfile(); userProfile.Created = DateTime.Now; contact = new Data.Contact(); address = new Data.Address(); account = new Account { CreatedAt = DateTime.Now }; string error = ""; user = Framework.Security.Manager.CreateUser(username, password, email, out error); user.AddGroup(Framework.Security.Group.FindByName("users")); user.AddGroup(Framework.Security.Group.FindByName("providers")); if (!string.IsNullOrEmpty(error)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = error }; } } DateTime expiresOn; if(!DateTime.TryParse(expires_on, out expiresOn)) { return new ReturnObject() { Error = true, StatusCode = 200, Message = "Invalide expiration date." }; } address.Street1 = street; address.Street2 = street_2; address.City = city; address.State = state; address.Zip = zip; address.Country = "United States"; address.Save(); contact.Email = email; contact.FirstName = first_name; contact.LastName = last_name; contact.Phone = phone; contact.Save(); provider.AddressID = address.ID; provider.PrimaryContactID = contact.ID; provider.Created = DateTime.Now; provider.FacilitySize = String.Empty; provider.Name = string.Empty; provider.Save(); var ut = Lib.Data.UserType.FindByName("provider"); userProfile.UserTypeID = ut.ID.Value; userProfile.UserID = user.ID.Value; userProfile.PrimaryAddressID = address.ID.Value; userProfile.PrimaryContactID = contact.ID.Value; userProfile.IsEcommerce = true; userProfile.Save(); providerUser.ProfileID = userProfile.ID.Value; providerUser.ProviderID = provider.ID.Value; providerUser.OrganizationID = 0; providerUser.ProviderUserType = ""; providerUser.PrimaryFacilityID = 0; providerUser.Save(); account.UserProifleId = userProfile.ID ?? 0; account.ExpiresOn = expiresOn; account.IsEnabled = is_enabled == "yes"; accountSvc.Save(account); return new ReturnObject() { Result = providerUser, Growl = new ReturnGrowlObject() { Type = "default", Vars = new ReturnGrowlVarsObject() { text = "You have successfully saved this provider user.", title = "Provider User Saved" } } }; }