コード例 #1
0
        /// <summary>
        /// The set default state of user.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="profile">
        /// The profile.
        /// </param>
        private static void SetDefaultStateOfUser(RegisterModel model, CustomProfile profile)
        {
            profile.IsTeacher         = "no";
            profile.FilledStudentInfo = "no";
            profile.Save();
            Roles.AddUserToRole(model.UserName, "Default");

            // Adds student to the "Default" role so we can force them to become a "Student" role.
        }
コード例 #2
0
        public ActionResult Create(CreateStudentViewModel studentModel, string selectedUser, string lastName,
                                   string firstMidName, string email)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var student = new Student();

                    //Establish the student data
                    student.UserName       = selectedUser;
                    student.LastName       = lastName;
                    student.FirstMidName   = firstMidName;
                    student.Email          = email;
                    student.EnrollmentDate = DateTime.Now;

                    db.Students.Add(student);                                   //inputs student data into database (is not saved yet)
                    db.SaveChanges();                                           //saves the student to database

                    MembershipUser user = Membership.GetUser(student.UserName); //gets the actual user
                    Roles.AddUserToRole(user.UserName, "Student");              //takes the user and sets role to student

                    // assigns Student data to the profile of the user (so the user is associated with this specified Student data)
                    CustomProfile profile = CustomProfile.GetUserProfile(student.UserName);
                    profile.FilledStudentInfo = "yes";
                    profile.Save();

                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                //Log the error (add a variable name after DataException)
                ModelState.AddModelError("",
                                         "Saving failed for some reason.  You may have left some information blank.  Please try again (several times in several different ways if possible (i.e. try using a different computer) - if the problem persists see your system administrator.");
            }

            // This code block is here to allow the page to render in case we get a DataException and have to re-display the screen.
            MembershipUserCollection users = Membership.GetAllUsers();
            var model = new CreateStudentViewModel
            {
                Users = users.OfType <MembershipUser>().Select(x => new SelectListItem
                {
                    Value = x.UserName,
                    Text  = x.UserName,
                })
            };

            return(View(model));
        }
コード例 #3
0
 /// <summary>
 /// The save new profile.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="profile">
 /// The profile.
 /// </param>
 private static void SaveNewProfile(RegisterModel model, CustomProfile profile)
 {
     profile.LastName            = model.LastName;
     profile.FirstMidName        = model.FirstMidName;
     profile.StreetAddress       = model.StreetAddress;
     profile.City                = model.City;
     profile.State               = model.State;
     profile.ZipCode             = model.ZipCode;
     profile.Phone               = model.Phone;
     profile.DateOfBirth         = model.DateOfBirth;
     profile.ParishAffiliation   = model.ParishAffiliation;
     profile.MinistryInvolvement = model.MinistryInvolvement;
     profile.Save();
 }
コード例 #4
0
        /// <summary>
        /// The save new profile data.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        private static void SaveNewProfileData(ProfileViewModel model, string state)
        {
            CustomProfile profile = CustomProfile.GetUserProfile();

            profile.LastName            = model.LastName;
            profile.FirstMidName        = model.FirstMidName;
            profile.StreetAddress       = model.StreetAddress;
            profile.City                = model.City;
            profile.State               = state;
            profile.ZipCode             = model.ZipCode;
            profile.Phone               = model.Phone;
            profile.DateOfBirth         = model.DateOfBirth;
            profile.ParishAffiliation   = model.ParishAffiliation;
            profile.MinistryInvolvement = model.MinistryInvolvement;
            profile.Save();
        }
コード例 #5
0
        protected void pageSave(Object sender, BrilliantWMS.ToolbarService.iUCToolbarClient e)
        {
            BrilliantWMS.UserCreationService.iUserCreationClient userClient = new BrilliantWMS.UserCreationService.iUserCreationClient();
            try
            {
                CustomProfile    profile      = CustomProfile.GetProfile();
                mUserProfileHead mUserProfile = new mUserProfileHead();
                mUserProfile = userClient.GetUserByID(profile.Personal.UserID, profile.DBConnection._constr);
                if (mUserProfile != null)
                {
                    mUserProfile.MobileNo             = txtMobile.Text.Trim();
                    mUserProfile.PhoneNo              = txtPhone.Text.Trim();
                    mUserProfile.EmailID              = txtEmailID.Text.Trim();
                    mUserProfile.OtherID              = txtOtherEmailID.Text.Trim();
                    mUserProfile.HighestQualification = txtHighestQualification.Text.Trim();
                    mUserProfile.InterestedIn         = txtInstratedIn.Text.Trim();
                    mUserProfile.ProfileImg           = (byte[])Session["ProfileImg"];
                    mUserProfile.DefaultAddress       = UCAddress1.BillingSeq.Trim();

                    mUserProfile.LastModifiedBy   = profile.Personal.UserID.ToString();
                    mUserProfile.LastModifiedDate = DateTime.Now;
                    userClient.UpdateUserProfile(mUserProfile, profile.DBConnection._constr);
                    UCAddress1.FinalSaveAddress(Address.ReferenceObjectName.User, profile.Personal.UserID);

                    profile.Personal.ProfileImg = mUserProfile.ProfileImg;
                    profile.Save();

                    WebMsgBox.MsgBox.Show("Profile updated successfully");
                }
            }
            catch (System.Exception ex)
            {
                Login.Profile.ErrorHandling(ex, this, "ProfileSetting", "pageSave");
            }
            finally { userClient.Close(); }
        }