protected void Page_Init(object sender, EventArgs e) { notifications = new List<Notifys>(); NumUnread = 0; User user = Manager.GetUser(); if(user == null) return; UserProfile userProfile = Security.GetCurrentProfile(); // if it's an ecommerce user we need to ensure the account is enabled and not expired _account = _accountSvc.GetByUserProfileId(userProfile.ID ?? 0); var nis = Lib.Data.NotificationInstance.FindNewForUser(user); UserId = user.ID ?? 0; NumUnread = ( from ni in nis where !ni.Read.HasValue select ni).Count(); var shortList = nis .OrderByDescending(x => x.Notification.Sent) .Take(5); foreach (var ni in shortList) { notifications.Add(new Notifys { notification = ni.Notification, read = ni.Read.HasValue }); } }
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" } } }; }
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" } } }; }
public void Save(Account account) { _accountRepo.Save(account); }
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); } }