예제 #1
0
        public static ReturnObject Prefs(HttpContext context, long? id = null, /*int email_frequency,*/ bool email_notifications = false)
        {
            var item = new UserPreferences(id);

            User currentUser = Framework.Security.Manager.GetUser();

            if(currentUser == null || currentUser.ID == null)
                return new ReturnObject { Error = true, Message = "Invalid user specified." };

            item.UserId = currentUser.ID.Value;
            item.EmailNotifications = email_notifications;
            item.Save();

            var ret = new ReturnObject()
            {
                Result = null,
                Growl = new ReturnGrowlObject()
                {
                    Type = "default",
                    Vars = new ReturnGrowlVarsObject()
                    {
                        text = "You have successfully updated your preferences.",
                        title = "Preferences Saved"
                    }
                }
            };

            return ret;
        }
예제 #2
0
        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");
        }
예제 #3
0
 protected void Page_Init(object sender, EventArgs e)
 {
     User user = Framework.Security.Manager.GetUser();
     UserPreferences = UserPreferences.FindByUser(user) ?? new UserPreferences();
 }