public static ReturnObject AttachProfile(HttpContext context, long id, string username, string password) { if(string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) ) return Failure(401, "Invalid username or password."); if(!Framework.Security.Manager.Login(username, password)) return Failure(401, "Invalid username or password."); UserProfile userProfile = UserProfile.FindByUser(Framework.Security.Manager.GetUser()); Data.Prescriber prescriber = Data.Prescriber.FindByProfile(userProfile); PrescriberProfile prescriberProfile = new PrescriberProfile(id); if(userProfile == null || prescriber == null || prescriberProfile == null) return Failure(404, "There does not appear to be a prescriber associate with your account."); prescriberProfile.AddressID = userProfile.PrimaryAddressID ?? 0; prescriberProfile.ContactID = userProfile.PrimaryContactID ?? 0; prescriberProfile.PrescriberID = prescriber.ID; prescriberProfile.Save(); 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" } } }; }
public static ReturnObject Edit(HttpContext context, long id, long prescriber_type) { PrescriberProfile profile = new PrescriberProfile(id); if(profile.ID == null) return new ReturnObject{Error = true, Message = "Invalid Request."}; profile.PrescriberTypeID = prescriber_type; profile.Save(); return new ReturnObject { Result = profile, Growl = new ReturnGrowlObject { Type = "default", Vars = new ReturnGrowlVarsObject { text = "Your information has been updated.", title = "Prescriber Profile Updated" } } }; }
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 ReturnObject Create(HttpContext context, string email, string first_name, string last_name, string phone_number, string message = null) { var provider = Security.GetCurrentProvider(); var providerProfile = ProviderUser.FindByProvider(provider).FirstOrDefault(); if( provider == null || string.IsNullOrEmpty(email) ) return new ReturnObject() { Error = true, Message = "Invalid Request." }; var contact = new Contact { FirstName = first_name, LastName = last_name, Email = email, Phone = phone_number, Fax = null }; contact.Save(); var address = new Address { Street1 = string.Empty, Street2 = null, City = string.Empty, State = string.Empty, Zip = string.Empty, Country = string.Empty }; address.Save(); var prescriberProf = new PrescriberProfile { Guid = Guid.NewGuid(), ProviderID = provider.ID.Value, ContactID = contact.ID.Value, AddressID = address.ID.Value, Expires = DateTime.Now.AddYears(1), PrimaryFacilityID = providerProfile.PrimaryFacilityID, OrganizationId = providerProfile.OrganizationID, Deleted = false, }; prescriberProf.Save(); var data = new Dictionary<string, object> { {"Message", (message != null)? message : "You have been invited to use the REMS Logic system. Please click the link below to complete your profile"}, {"Token", prescriberProf.Guid}, {"Year", DateTime.Now.Year.ToString()}, {"EmailAddress", email} }; var overrides = new Framework.Email.TemplateOverrides { To = new [] { new MailAddress(email) } }; Email.SendTemplate("PrescriberInvite", data, overrides); return new ReturnObject { Result = prescriberProf, Actions = new List<ReturnActionObject>(new ReturnActionObject[] { new ReturnActionObject { Type = "back" } }), Growl = new ReturnGrowlObject { Type = "default", Vars = new ReturnGrowlVarsObject { text = "Your invite has been sent", title = "Prescriber Invited" } } }; }
public static ReturnObject Update(HttpContext context, long id, string agree_to_terms, 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 = 0; // get the prescriber type PrescriberType type = PrescriberType.FindByDisplayName(prescriber_type); if(type != null) profile.PrescriberTypeID = type.ID; profile.Save(); return Success( "Profile Updated", "Your profile has been updated.", null, "Ecommerce.aspx#ecommerce/wizards/etasu-selections"); }