Ejemplo n.º 1
0
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Event handler for page load event
        try {
            if (!Page.IsPostBack)
            {
                //Get query request and setup for new or existing user
                this.mUserName = new MembershipServices().Username;
                ViewState.Add("username", this.mUserName);

                //  Membership
                MembershipUser member = Membership.GetUser(this.mUserName, false);
                this.txtUserName.Text    = member.UserName;
                this.txtUserName.Enabled = false;
                this.txtEmail.Text       = member.Email;
                //try { if(!member.IsLockedOut) this.txtPassword.Text = member.GetPassword(); } catch { }
                //this.txtComments.Text = member.Comment;

                //  Profile
                ProfileCommon profileCommon = new ProfileCommon();
                ProfileCommon profile       = profileCommon.GetProfile(this.mUserName);
                this.txtFullName.Text = profile.UserFullName;
                this.txtCompany.Text  = profile.Company;
                //this.txtCompanyType.Text = profile.Type;
                //this.txtCustomer.Text = profile.ClientVendorID;
                this.txtStoreNumber.Text = profile.StoreNumber;
            }
            else
            {
                this.mUserName = ViewState["username"].ToString();
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 3); }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the user and profile.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <returns></returns>
        public static string CreateUserAndProfile(UserDetails user)
        {
            if (user.IsValid)
            {
                //save profile details too
                ProfileCommon p          = new ProfileCommon();
                ProfileCommon newProfile = p.GetProfile(user.UserName);
                newProfile.WarehouseId     = user.WarehouseId;
                newProfile.RegionId        = user.RegionId;
                newProfile.OpCoId          = user.OpCoId;
                newProfile.SalesLocationId = user.SalesLocationId;
                newProfile.OpCoCode        = "";
                newProfile.RegionCode      = "";
                if (user.OpCoId != -1)
                {
                    newProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code;
                }

                if (user.RegionId != -1)
                {
                    newProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code;
                }

                newProfile.Save();


                Membership.CreateUser(user.UserName, user.NewPassword, user.Email);
                return(user.UserName);
            }
            return("");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:UserDetails"/> class.
        /// </summary>
        /// <param name="membershipUser">The membership user.</param>
        /// <param name="getProfile">if set to <c>true</c> [get profile].</param>
        public UserDetails(MembershipUser membershipUser, bool getProfile)
        {
            if (membershipUser != null)
            {
                UserName         = membershipUser.UserName;
                Email            = membershipUser.Email;
                LastActivityDate = membershipUser.LastActivityDate.ToShortDateString();

                if (getProfile)
                {
                    ProfileCommon p       = new ProfileCommon();
                    ProfileCommon profile = p.GetProfile(membershipUser.UserName);


                    if (profile != null)
                    {
                        OpCoId          = profile.OpCoId;
                        OpCoCode        = profile.OpCoCode;
                        RegionId        = profile.RegionId;
                        RegionCode      = profile.RegionCode;
                        WarehouseId     = profile.WarehouseId;
                        SalesLocationId = profile.SalesLocationId;
                        SalesLocation   = SalesLocationController.GetLocation(salesLocationId, false);
                        OpCo            = OpcoController.GetOpCo(OpCoId, false);
                        Warehouse       = WarehouseController.GetWarehouse(WarehouseId);
                        Region          = OptrakRegionController.GetRegion(RegionId);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public ActionResult Detail(string key)
        {
            var obj        = new UserModel();
            var membership = Membership.GetUser(key);
            var profile    = ProfileCommon.GetProfile(key);

            obj.UserID = membership.UserName;

            if (profile != null)
            {
                obj.RoleID   = profile.RoleID;
                obj.IsActive = profile.IsActive;
            }

            if (obj.RoleID != 0)
            {
                var role = new RoleBFC().RetrieveByID(obj.RoleID);
                obj.RoleName = role.Name;
            }

            ViewBag.Mode = UIMode.Detail;

            SetViewBagNotification();
            SetViewBagPermission();

            return(View(obj));
        }
Ejemplo n.º 5
0
        public ActionResult UpdateFlightReview(int pilotId)
        {
            FlightReviewViewModel viewModel = new FlightReviewViewModel();

            viewModel.PilotId = pilotId;
            ProfileCommon profile = ProfileCommon.GetProfile();

            Member member = _dataService.GetMemberWithPilotData(pilotId);

            viewModel.PilotId   = pilotId;
            viewModel.PilotName = member.FullName;

            viewModel.InstructorId   = profile.MemberId;
            viewModel.InstructorName = profile.FirstName + " " + profile.LastName;

            if (member.FlightReviews != null && member.FlightReviews.Count() > 0)
            {
                FlightReview lastReview = member.FlightReviews.OrderByDescending(r => r.Date).First();
                viewModel.TotalTime   = lastReview.TotalTime;
                viewModel.RetractTime = lastReview.RetractTime;
            }
            viewModel.ReviewDate = DateTime.Now;

            return(View(ViewNames.UpdateFlightReview, viewModel));
        }
Ejemplo n.º 6
0
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        TextBox eMail     = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
        TextBox firstName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName");
        TextBox lastName  = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName");
        TextBox userName  = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
        TextBox userPw    = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password");

        //Log in user programatically.

        if (Membership.ValidateUser(userName.Text, userPw.Text))
        {
            ProfileCommon pc      = new ProfileCommon();
            ProfileCommon userPro = pc.GetProfile(userName.Text);

            //First set profile properties.

            userPro.EMail     = eMail.Text;
            userPro.FirstName = firstName.Text;
            userPro.LastName  = lastName.Text;
            userPro.Save();

            // Next add user to ProfileProperty table.

            UserClass uc = new UserClass(userPro.UserName);
            uc.SignUpUser(eMail.Text, firstName.Text, lastName.Text);
        }
    }
Ejemplo n.º 7
0
        public ActionResult AddStageCheck(int pilotId)
        {
            Member pilot = _dataService.GetMemberWithPilotData(pilotId);

            AddStageCheckViewModel viewModel = new AddStageCheckViewModel();

            viewModel.CheckDate = DateTime.Now;
            viewModel.PilotId   = pilotId;
            viewModel.PilotName = pilot.FullName;

            viewModel.AvailableStages = new Dictionary <string, string>();
            string[] stagenames = Enum.GetNames(typeof(StageChecks));
            foreach (var name in stagenames)
            {
                if (!pilot.StageChecks.Any(s => s.StageName == name))
                {
                    viewModel.AvailableStages.Add(name, name.ToFriendlyString());
                }
            }

            int    instructorId = ProfileCommon.GetProfile().MemberId;
            Member instructor   = _dataService.GetMember(instructorId);

            viewModel.InstructorId   = instructor.Id;
            viewModel.InstructorName = instructor.FullName;

            return(View(ViewNames.AddStageCheck, viewModel));
        }
Ejemplo n.º 8
0
        private static List <string> GetMenu(string userName)
        {
            var profile      = ProfileCommon.GetProfile(userName);
            var roleMenuList = new RoleBFC().RetrieveDetails(profile.RoleID).Select(p => p.ModuleID).Distinct();

            return(roleMenuList.ToList());
        }
Ejemplo n.º 9
0
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
        TextBox eMail     = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
        TextBox firstName = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName");
        TextBox lastName  = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName");
        TextBox userName  = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");

        ProfileCommon pc      = new ProfileCommon();
        ProfileCommon userPro = pc.GetProfile(userName.Text);

        //First set profile properties.

        userPro.EMail = eMail.Text;
        if (userPro.FirstName != "" && userPro.FirstName != null)
        {
            userPro.FirstName = firstName.Text;
        }
        if (userPro.LastName != "" && userPro.LastName != null)
        {
            userPro.LastName = lastName.Text;
        }
        userPro.Save();

        // Next add user to ProfileProperty table.

        UserClass uc = new UserClass(userPro.UserName);

        uc.SignUpUser(eMail.Text, firstName.Text, lastName.Text);
    }
Ejemplo n.º 10
0
    public MembershipDS GetTrackingUsers()
    {
        //
        ProfileCommon profileCommon = new ProfileCommon();
        ProfileCommon profile       = null;
        string        email         = "";

        string[]     users  = Roles.GetUsersInRole(TRACKINGROLE);
        MembershipDS member = new MembershipDS();

        //Append members
        for (int i = 0; i < users.Length; i++)
        {
            email   = Membership.GetUser(users[i]).Email;
            profile = profileCommon.GetProfile(users[i]);
            if (profile.Type.Length == 0)
            {
                profile.Type = "client";
            }
            if (profile.ClientVendorID.Length == 0)
            {
                profile.ClientVendorID = TrackingServices.ID_ARGIX;
            }
            member.MemberTable.AddMemberTableRow(profile.UserName, profile.UserFullName, email, profile.Company, profile.Type, profile.ClientVendorID, profile.WebServiceUser, profile.LastActivityDate, profile.LastUpdatedDate);
        }
        member.AcceptChanges();
        return(member);
    }
Ejemplo n.º 11
0
        protected void bt_Submit_Click(object sender, EventArgs e)
        {
            string   UserName = last_name.Text.Trim();
            string   Email    = EMailId.Text.Trim();
            string   Password = password.Text.Trim();
            char     gender   = char.Parse(dl_gender.SelectedValue);
            DateTime DOB      = DateTime.Parse(date.Value.ToString());

            try
            {
                MembershipUser user = Membership.CreateUser(Email, Password);
                Roles.AddUserToRole(user.UserName, "traveluser");
                ProfileCommon com = ProfileCommon.GetProfile(Email);
                com.Personal.FullName    = UserName;
                com.Personal.Gender      = gender;
                com.Personal.DateOfBirth = DOB;
                com.Save();
                Response.Redirect("Register_Success.aspx", false);
            }
            catch (MembershipCreateUserException ex)
            {
                if (ex.StatusCode == MembershipCreateStatus.InvalidPassword)
                {
                    lb_password_error.Visible = true;
                    lb_password_error.Text    = "Invalid password";
                }
                else if (ex.StatusCode == MembershipCreateStatus.InvalidEmail)
                {
                    email_error.Visible = true;
                    email_error.Text    = "Invalid e-mail";
                }
                else if (ex.StatusCode == MembershipCreateStatus.InvalidUserName)
                {
                    lb_error_username.Visible = true;
                    lb_error_username.Text    = "Invalid user name";
                }
                else if (ex.StatusCode == MembershipCreateStatus.DuplicateEmail)
                {
                    email_error.Visible = true;
                    email_error.Text    = "E-mail id already present";
                }
                else if (ex.StatusCode == MembershipCreateStatus.DuplicateUserName)
                {
                    lb_error_username.Visible = true;
                    lb_error_username.Text    = "Login Id  already present";
                }

                else
                {
                    gendral_error.Visible = true;
                    gendral_error.Text    = "Sorry !!! Unable to register. Please try again";
                }
            }
            catch (Exception ex)
            {
                gendral_error.Visible = true;
                gendral_error.Text    = "Sorry !!! Unable to register. Please try again";
            }
        }
Ejemplo n.º 12
0
        protected void Submit_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValid)
                {
                    DateTime dtDOB;
                    date.Text = date.Text.Trim();
                    bool blnIsValidDate = DateTime.TryParseExact(date.Text, "M/d/yyyy", null, System.Globalization.DateTimeStyles.None, out dtDOB);

                    if (Name.Text.Length == 0)
                    {
                        UpdateLabel.Text = "Name can't be empty";
                        UpdateLabel_container.Visible = true;
                        Name.Focus();
                    }
                    else if (date.Text.Length == 0)
                    {
                        UpdateLabel.Text = "Date of Birth can't be empty";
                        UpdateLabel_container.Visible = true;
                        date.Focus();
                    }
                    else if (!blnIsValidDate)
                    {
                        UpdateLabel.Text = "Please enter a valid Date of Birth";
                        UpdateLabel_container.Visible = true;
                        date.Focus();
                    }
                    else if (dtDOB > DateTime.Now)
                    {
                        UpdateLabel.Text = "Date of Birth should be lesser than Current Date";
                        UpdateLabel_container.Visible = true;
                        date.Focus();
                    }
                    else
                    {
                        ProfileCommon com = ProfileCommon.GetProfile(Membership.GetUser().UserName.ToString());
                        com.Personal.FullName    = Name.Text;
                        com.Personal.Gender      = Convert.ToChar(Gender.SelectedValue.ToString());
                        com.Personal.DateOfBirth = Convert.ToDateTime(date.Text);
                        com.Contact.Address      = Address1.Text;
                        com.Contact.City         = City.Text;
                        com.Contact.MobileNo     = MobileNo.Text;
                        com.Contact.PinCode      = Pincode.Text;
                        com.Contact.State        = State.Text;
                        com.Save();
                        Response.Redirect("~/Account/UpdateProfile.aspx", false);
                    }
                }

                hdnShowEditControls.Value = "1";
            }
            catch (Exception ex)
            {
                UpdateLabel.Text = "Sorry !!! Unable to Update your account. Please try again";
                UpdateLabel_container.Visible = true;
                hdnShowEditControls.Value     = "1";
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Get the outlookname from a UserID.
        /// Fx. "TRR-123 Lastname, Middlename Firstname"
        /// </summary>
        /// <param name="userID">The UserID to use</param>
        /// <returns></returns>
        public static string GetOutlookName(Guid userID)
        {
            ProfileCommon profile = new ProfileCommon();

            profile = profile.GetProfile(Membership.GetUser(userID).UserName);

            return(GetOutlookName(profile));
        }
Ejemplo n.º 14
0
    //Interface
    protected void Page_Load(object sender, EventArgs e)
    {
        //Event handler for page load event
        if (!Page.IsPostBack)
        {
            //Get query request and setup for new or existing user
            this.mUserName = Request.QueryString["username"] == null ? "" : Request.QueryString["username"].ToString();
            ViewState.Add("username", this.mUserName);
            if (this.mUserName.Length == 0)
            {
                //New member
            }
            else
            {
                //Existing member
                //  Membership
                MembershipUser member = Membership.GetUser(this.mUserName, false);
                this.txtUserName.Text = member.UserName;
                this.txtEmail.Text    = member.Email;
                try { if (!member.IsLockedOut)
                      {
                          this.txtPassword.Text = member.GetPassword();
                      }
                } catch (Exception ex) { Master.ReportError(ex, 3); }
                this.txtComments.Text     = member.Comment;
                this.chkApproved.Checked  = member.IsApproved;
                this.chkLockedOut.Checked = member.IsLockedOut;

                //  Profile
                ProfileCommon profileCommon = new ProfileCommon();
                ProfileCommon profile       = profileCommon.GetProfile(this.mUserName);
                this.txtCompany.Text = profile.ClientID;

                //  Roles
                if (Roles.IsUserInRole(this.mUserName, MembershipServices.GUESTROLE))
                {
                    this.optRole.SelectedValue = MembershipServices.GUESTROLE;
                }
                else if (Roles.IsUserInRole(this.mUserName, MembershipServices.ADMINROLE))
                {
                    this.optRole.SelectedValue = MembershipServices.ADMINROLE;
                }
                else if (Roles.IsUserInRole(this.mUserName, MembershipServices.SALESROLE))
                {
                    this.optRole.SelectedValue = MembershipServices.SALESROLE;
                }
                else if (Roles.IsUserInRole(this.mUserName, MembershipServices.CLIENTROLE))
                {
                    this.optRole.SelectedValue = MembershipServices.CLIENTROLE;
                }
            }
            OnValidateForm(null, EventArgs.Empty);
        }
        else
        {
            this.mUserName = ViewState["username"].ToString();
        }
    }
Ejemplo n.º 15
0
        private static bool SaveChangesToLiveDB(Latekick.BOL.AccountManagement.User u)
        {
            ProfileCommon pc = new ProfileCommon();
            ProfileCommon pb = pc.GetProfile(u.UserName);

            pb.Balance = u.Balance;
            pb.Save();
            return(true);
        }
Ejemplo n.º 16
0
        public static bool RefreshBalance(Latekick.BOL.AccountManagement.User u)
        {
            ProfileCommon pc = new ProfileCommon();
            ProfileCommon pb = pc.GetProfile(u.UserName);

            u.Currency = pb.Currency;
            u.Balance  = pb.Balance;
            return(true);
        }
Ejemplo n.º 17
0
    public static List <ADUCUser> GetList(MembershipUserCollection users, ProfileCommon profile)
    {
        List <ADUCUser> result = new List <ADUCUser>();

        foreach (MembershipUser user in users)
        {
            result.Add(new ADUCUser(user, profile.GetProfile(user.UserName)));
        }

        return(result);
    }
        public bool IsValidAnswerToQuestion2(string Answer2)
        {
            ProfileCommon profile   = ProfileCommon.GetProfile();
            string        OriANswer = profile.SecurityQuestions.Answer2.ToLower();
            bool          Equals    = false;

            if (OriANswer != "")
            {
                Equals = OriANswer.Equals(Answer2.ToLower());
            }

            return(Equals);
        }
Ejemplo n.º 19
0
        public static void InitializeTestClass(TestContext context)
        {
            // Clean up common usernames used accross the different tests.
            foreach (string username in commonUsernamesUsedInTests)
            {
                ProfileCommon profile = ProfileCommon.GetProfile(username);

                if (profile != null)
                {
                    System.Web.Profile.ProfileManager.DeleteProfile(username);
                }
            }
        }
Ejemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    if (Membership.GetUser() != null)
                    {
                        ProfileCommon com = ProfileCommon.GetProfile(Membership.GetUser().UserName.ToString());

                        UpdateLabel.Text = "";
                        UpdateLabel_container.Visible = false;
                        DateTime dateOnly = com.Personal.DateOfBirth;

                        Name.Text     = com.Personal.FullName;
                        date.Text     = dateOnly.ToShortDateString();
                        Address1.Text = com.Contact.Address;
                        City.Text     = com.Contact.City;
                        State.Text    = com.Contact.State;
                        Pincode.Text  = com.Contact.PinCode;
                        MobileNo.Text = com.Contact.MobileNo;

                        if (com.Personal.Gender == 'M' || com.Personal.Gender == 'm')
                        {
                            lbgender.Text        = "Male";
                            Gender.SelectedIndex = 1;
                        }
                        else
                        {
                            lbgender.Text        = "Female";
                            Gender.SelectedIndex = 2;
                        }
                        lbname.Text = com.Personal.FullName;
                        //lbDOB.Text = dateOnly.ToShortDateString();
                        lbDOB.Text     = dateOnly.ToString("M/d/yyyy");
                        lbAddress.Text = com.Contact.Address;
                        lbCity.Text    = com.Contact.City;
                        lbState.Text   = com.Contact.State;
                        lbPib.Text     = com.Contact.PinCode;
                        lbMobile.Text  = com.Contact.MobileNo;
                    }
                }
                catch (Exception ex)
                {
                    UpdateLabel.Text = "Sorry !!! Unable to fetch your account details. Please try again";
                    UpdateLabel_container.Visible = true;
                }
            }
        }
Ejemplo n.º 21
0
        public ActionResult Create(CreateSquawkViewModel model)
        {
            if (ModelState.IsValid)
            {
                Squawk squawk = new Squawk()
                {
                    AircraftId     = model.AircraftId,
                    Subject        = model.Subject,
                    Description    = model.Description,
                    GroundAircraft = model.GroundAircraft,
                    PostedById     = ProfileCommon.GetProfile().MemberId,
                    PostedOn       = DateTime.Now,
                    Status         = SquawkStatus.Open.ToString()
                };
                _dataService.AddSquawk(squawk);

                if (model.GroundAircraft)
                {
                    _dataService.UpdateAircraftStatus(model.AircraftId, AircraftStatus.Grounded.ToString());
                }

                try
                {
                    Aircraft aircraft = _dataService.GetAircraftById(model.AircraftId);

                    MailMessage message = new MailMessage();
                    message.Subject = "Squawk posted for " + aircraft.RegistrationNumber;
                    message.From    = new MailAddress("*****@*****.**");
                    message.Body    = model.Subject + "\t";
                    message.Body   += model.Description;

                    List <Member> owners = _dataService.GetAircraftOwners(model.AircraftId);
                    foreach (var owner in aircraft.Owners)
                    {
                        message.To.Add(new MailAddress(owner.Login.Email));
                    }

                    SendEmail(message);
                }
                catch (Exception ex)
                {
                    LogError("Error while sending squawk notification email for aircraftId " + model.AircraftId + "\t" + ex.ToString());
                }

                return(RedirectToAction("ListActiveSquawks"));
            }

            return(View(model));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Updates the user and profile.
        /// </summary>
        /// <param name="user">The user.</param>
        public static string UpdateUserAndProfile(UserDetails user)
        {
            if (user.IsValid)
            {
                MembershipUser membershipUser = Membership.GetUser(user.UserName);
                membershipUser.Email = user.Email;
                bool success = true;
                if (!string.IsNullOrEmpty(user.OldPassword) && !string.IsNullOrEmpty(user.NewPassword))
                {
                    success = membershipUser.ChangePassword(user.OldPassword, user.NewPassword);
                }
                if (success)
                {
                    Membership.UpdateUser(membershipUser);

                    //update profile too
                    ProfileCommon p = new ProfileCommon();
                    ProfileCommon selectedProfile = p.GetProfile(user.UserName);
                    selectedProfile.WarehouseId     = user.WarehouseId;
                    selectedProfile.RegionId        = user.RegionId;
                    selectedProfile.SalesLocationId = user.SalesLocationId;
                    selectedProfile.OpCoId          = user.OpCoId;
                    selectedProfile.OpCoCode        = "";
                    selectedProfile.RegionCode      = "";
                    if (user.OpCoId != -1)
                    {
                        selectedProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code;
                    }

                    if (user.RegionId != -1)
                    {
                        selectedProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code;
                    }

                    selectedProfile.Save();

                    return(user.UserName);
                }
                else
                {
                    throw new SystemException("The Password has not be successfully changed.");
                }
            }
            return("");
        }
Ejemplo n.º 23
0
        public ActionResult PilotReview(int memberId)
        {
            PilotReviewViewModel viewModel = new PilotReviewViewModel();
            Member member = _dataService.GetMemberWithPilotData(memberId);

            viewModel = InitializePilotReviewViewModel(member);
            if (User.IsInRole(UserRoles.Admin.ToString()))
            {
                viewModel.CanEditStageChecks = true;
            }
            else
            {
                int instructorId = ProfileCommon.GetProfile().MemberId;
                viewModel.CanEditStageChecks = _dataService.IsDesignatedForStageChecks(instructorId);
            }

            return(View(ViewNames.PilotReview, viewModel));
        }
Ejemplo n.º 24
0
        public void CheckOrGenerateAdministrator()
        {
            string username = "******";
            string password = "******";
            MembershipUserCollection listOfUserNameByName = Membership.FindUsersByName(username);

            if (listOfUserNameByName.Count == 0)
            {
                MembershipUser m = Membership.CreateUser(username, password);
                ProfileCommon.Create(username).Save();
                ProfileCommon p = ProfileCommon.GetProfile(username);
                p.RoleID   = (int)PermissionType.Administrator;
                p.IsActive = true;
                p.Save();

                new UserProfileBFC().Create(username, "System");
            }
        }
Ejemplo n.º 25
0
        public ActionResult Create(UserModel user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    Validate(user);

                    using (TransactionScope trans = new TransactionScope())
                    {
                        Membership.CreateUser(user.UserID, user.Password);

                        var profile = ProfileCommon.GetProfile(user.UserID);
                        profile.RoleID   = user.RoleID;
                        profile.IsActive = user.IsActive;


                        trans.Complete();
                    }
                    /*Create User Profile*/
                    new UserProfileBFC().Create(user.UserID, MembershipHelper.GetUserName());

                    TempData["SuccessNotification"] = "Document has been saved";

                    return(RedirectToAction("Detail", new { key = user.UserID }));
                }
                catch (Exception ex)
                {
                    ViewBag.Mode = UIMode.Create;
                    ViewBag.ErrorNotification = ex.Message;
                    SetPreEditViewBag();

                    return(View(user));
                }
            }
            else
            {
                ViewBag.ErrorNotification = "Object is invalid";
            }

            ViewBag.Mode = UIMode.Create;
            SetPreEditViewBag();
            return(View(user));
        }
Ejemplo n.º 26
0
        public ActionResult Index(int?pageIndex, int?amount, string sortParameter, string filterBy, string filterKey)
        {
            if (pageIndex == null)
            {
                pageIndex = 1;
            }

            int startIndex = Convert.ToInt32(pageIndex * amount);

            var userList       = new List <UserModel>();
            var membershipList = Membership.GetAllUsers();

            var roleList = new RoleBFC().RetrieveAll();

            foreach (MembershipUser membershipUser in membershipList)
            {
                var user = new UserModel();
                user.UserID = membershipUser.UserName;

                var profile = ProfileCommon.GetProfile(membershipUser.UserName);

                var query = from i in roleList
                            where i.ID == profile.RoleID
                            select i;

                if (query.FirstOrDefault() != null)
                {
                    user.RoleID   = query.FirstOrDefault().ID;
                    user.RoleName = query.FirstOrDefault().Name;
                }

                userList.Add(user);
            }

            ViewBag.ControllerName = "User";
            ViewBag.PageIndex      = pageIndex;
            ViewBag.PageCount      = Math.Floor(Convert.ToDecimal(membershipList.Count / SystemConstants.ItemPerPage)) + 1;
            ViewBag.SortParameter  = sortParameter;
            ViewBag.FilterKey      = filterKey;

            SetViewBagPermission();

            return(View(userList));
        }
Ejemplo n.º 27
0
        public ActionResult Update(UserModel user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (!string.IsNullOrEmpty(user.Password))
                    {
                        Validate(user);

                        var membershipUser = Membership.GetUser(user.UserID);

                        membershipUser.ChangePassword(membershipUser.ResetPassword(), user.Password);
                    }

                    var profile = ProfileCommon.GetProfile(user.UserID);
                    profile.RoleID   = user.RoleID;
                    profile.IsActive = user.IsActive;

                    MenuHelper.ResetMenu(user.UserID);

                    TempData["SuccessNotification"] = "Document has been updated";

                    return(RedirectToAction("Detail", new { key = user.UserID }));
                }
                catch (Exception ex)
                {
                    ViewBag.Mode = UIMode.Update;
                    ViewBag.ErrorNotification = ex.Message;
                    SetPreEditViewBag();

                    return(View(user));
                }
            }
            else
            {
                ViewBag.ErrorNotification = "Object is invalid";
            }

            ViewBag.Mode = UIMode.Update;
            SetPreEditViewBag();

            return(View(user));
        }
Ejemplo n.º 28
0
        protected void RegisterUser_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            //save Security Questions in Profile:
            ProfileCommon profile = ProfileCommon.GetProfile();

            profile.SecurityQuestions.Question1 = txtQuestion1.Text;
            profile.SecurityQuestions.Answer1   = txtAnswer1.Text;
            profile.SecurityQuestions.Question2 = txtQuestion2.Text;
            profile.SecurityQuestions.Answer2   = txtAnswer2.Text;
            profile.Save();


            string continueUrl = RegisterUser.ContinueDestinationPageUrl;

            if (String.IsNullOrEmpty(continueUrl))
            {
                continueUrl = "~/";
            }
            Response.Redirect(continueUrl);
        }
Ejemplo n.º 29
0
    protected void OnCommand(object sender, CommandEventArgs e)
    {
        //Event handler for cancel button clicked
        MembershipUser member = null;

        try {
            switch (e.CommandName)
            {
            case "Update":
                if (!Page.IsValid)
                {
                    return;
                }
                //Update existing user if account is not locked
                member = Membership.GetUser(this.mUserName);
                if (member.IsLockedOut)
                {
                    Master.ShowMessageBox(this.mUserName + " account must be unlocked before updating.");
                    return;
                }
                //Membership
                member.Email = this.txtEmail.Text;
                //member.Comment = this.txtComments.Text;
                Membership.UpdateUser(member);

                //Profile
                ProfileCommon profileCommon = new ProfileCommon();
                ProfileCommon profile       = profileCommon.GetProfile(this.mUserName);
                profile.UserFullName = this.txtFullName.Text;
                profile.Save();

                System.Text.StringBuilder script = new System.Text.StringBuilder();
                script.Append("<script language=javascript>");
                script.Append("\talert('Your profile has been updated.');");
                script.Append("</script>");
                Page.ClientScript.RegisterStartupScript(typeof(Page), "ProfileUpdated", script.ToString());
                break;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 3); }
    }
Ejemplo n.º 30
0
        public ActionResult Update(string key)
        {
            var obj        = new UserModel();
            var membership = Membership.GetUser(key);
            var profile    = ProfileCommon.GetProfile(key);

            obj.UserID   = membership.UserName;
            obj.RoleID   = profile.RoleID;
            obj.IsActive = profile.IsActive;

            if (obj.RoleID != 0)
            {
                var role = new RoleBFC().RetrieveByID(obj.RoleID);
                obj.RoleName = role.Name;
            }

            ViewBag.Mode = UIMode.Update;
            SetPreEditViewBag();

            return(View(obj));
        }
 /// <summary>
 /// just remove all the properties and values from particular user and group's profile but the empty instance exists  
 /// </summary>
 /// <param name="userName"></param>
 /// <param name="groupName"></param>
 /// <returns></returns>
 public bool RemoveProfileByUserGroup(string userName,string groupName)
 {
     ProfileCommon pc = new ProfileCommon();
     ProfileCommon existing_pc = pc.GetProfile(userName);
     try{
         Dictionary<string,object> profile = (Dictionary<string,object>)existing_pc.GetProfileGroup(groupName).GetPropertyValue("properties_block");
         profile.Clear();
         if(!SetProfile(groupName,userName,profile).Equals("success"))
             return false;
     }
     catch(Exception e)
     {
         return false;
     }
     return true;
 }
        /// <summary>
        /// remove only provided properties from particular user and group's profile 
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="groupName"></param>
        /// <param name="propertyNameList"></param>
        /// <returns></returns>
        public bool RemoveProfilePropertiesByUserGroup(string userName,string groupName,ArrayList propertyNameList)
        {
            Dictionary<string, object> existPropertiesDictionary = new Dictionary<string,object>();
            ProfileCommon pc = new ProfileCommon();
            ProfileCommon existing_pc = pc.GetProfile(userName);

            Dictionary<string,object> profileDictionary = (Dictionary<string,object>)existing_pc.GetProfileGroup(groupName).GetPropertyValue("properties_block");

            if(profileDictionary.Keys.Count > 0)
            {
                propertyDepth = "";
                existPropertiesDictionary = DeleteProperties(profileDictionary,propertyNameList);
            }

            if(!SetProfile(groupName,userName,existPropertiesDictionary).Equals("success"))
                 return false;

            return true;
        }
        /// <summary>
        /// set the profile dictionary according to merchant_group and user_name 
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="username"></param>
        /// <param name="userProfile"></param>
        /// <returns>return "success" if profile is inserted successfully otherwise return "error!![error_text]"</returns>
        public string SetProfile(string groupName,string userName,Dictionary<string,object> userProfile)
        {
            if(Membership.GetUser(userName) == null)
                Membership.CreateUser(userName,"1234567");
            try
            {
                ProfileCommon pc = new ProfileCommon();
                ProfileCommon existing_pc = pc.GetProfile(userName);
                existing_pc.GetProfileGroup(groupName).SetPropertyValue("properties_block",userProfile);

                existing_pc.Save();

            }
            catch(Exception e)
            {
                return "error!!" + e;
            }
            return "success";
        }
        /// <summary>
        /// get profiles of all users with metioned properties for particular groupName 
        /// </summary>
        /// <param name="groupName"></param>
        /// <param name="propertyNameList"></param>
        /// <returns>return a dictionary object that holds "user_name" as a key and total properties_block(dictionary object) for that particular user as a value</returns>
        public Dictionary<string, object> GetProfilesByGroup(string groupName,ArrayList propertyNameList)
        {
            Dictionary<string, object> profileListDictionary = new Dictionary<string, object>();
            ProfileCommon pc = new ProfileCommon();

            MembershipUserCollection userList = Membership.GetAllUsers();
            foreach(MembershipUser user in userList)
            {
                ProfileCommon existing_pc = pc.GetProfile(user.UserName);

                Dictionary<string,object> profileDictionary = (Dictionary<string,object>)existing_pc.GetProfileGroup(groupName).GetPropertyValue("properties_block");

                if(profileDictionary.Keys.Count > 0)
                {
                    propertyDepth = "";
                    Dictionary<string, object> selectedPropertiesDictionary = new Dictionary<string,object>();
                    selectedPropertiesDictionary = FindProperties(profileDictionary,selectedPropertiesDictionary,propertyNameList);

                    if(selectedPropertiesDictionary.Keys.Count > 0)
                        profileListDictionary.Add(user.UserName,selectedPropertiesDictionary);
                }

            }

            return profileListDictionary;
        }
        /// <summary>
        /// get only metioned properties of profile for all user and group
        /// </summary>
        /// <param name="propertyNameList"></param>
        /// <returns>return a dictionary object that holds "user_name|merchant_Group_Name" as a key and total properties_block(dictionary object) for that particular user and group as a value</returns>
        public Dictionary<string, object> GetTotalProfileCollection(ArrayList propertyNameList)
        {
            Dictionary<string, object> profileListDictionary = new Dictionary<string, object>();
            MembershipUserCollection userList = Membership.GetAllUsers();
            foreach(MembershipUser user in userList)
            {
                ProfileCommon pc = new ProfileCommon();
                ProfileCommon existing_pc = pc.GetProfile(user.UserName);

                string []groupNameArray = Enum.GetNames(typeof(ProfileTypeEnum));

                for(int i=0;i<groupNameArray.Length;i++)
                {
                    Dictionary<string,object> profileDictionary = (Dictionary<string,object>)existing_pc.GetProfileGroup(groupNameArray[i]).GetPropertyValue("properties_block");
                    if(profileDictionary.Keys.Count > 0)
                    {
                        propertyDepth = "";
                        Dictionary<string, object> selectedPropertiesDictionary = new Dictionary<string,object>();
                        selectedPropertiesDictionary = FindProperties(profileDictionary,selectedPropertiesDictionary,propertyNameList);

                        if(selectedPropertiesDictionary.Keys.Count > 0)
                            profileListDictionary.Add(user.UserName+"|"+groupNameArray[i],selectedPropertiesDictionary);
                    }
                }

            }
            return profileListDictionary;
        }
        /// <summary>
        /// get all profiles of all groups with metioned properties for particular user 
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="propertyNameList"></param>
        /// <returns>return a dictionary object that holds "group_name" as a key and total properties_block(dictionary object) for that particular group as a value</returns>
        public Dictionary<string, object> GetProfilesByUser(string userName,ArrayList propertyNameList)
        {
            Dictionary<string, object> profileListDictionary = new Dictionary<string, object>();
            ProfileCommon pc = new ProfileCommon();
            ProfileCommon existing_pc = pc.GetProfile(userName);

            string []groupNameArray = Enum.GetNames(typeof(ProfileTypeEnum));

            for(int i=0;i<groupNameArray.Length;i++)
            {
                Dictionary<string,object> profileDictionary = (Dictionary<string,object>)existing_pc.GetProfileGroup(groupNameArray[i]).GetPropertyValue("properties_block");
                if(profileDictionary.Keys.Count > 0)
                {
                    propertyDepth = "";
                    Dictionary<string, object> selectedPropertiesDictionary = new Dictionary<string,object>();
                    selectedPropertiesDictionary = FindProperties(profileDictionary,selectedPropertiesDictionary,propertyNameList);

                    if(selectedPropertiesDictionary.Keys.Count > 0)
                        profileListDictionary.Add(groupNameArray[i],selectedPropertiesDictionary);
                }
            }
            return profileListDictionary;
        }
Ejemplo n.º 37
0
    public bool CreateEnrollment(string username, string email, string password, string firstname ,string  lastname ,string  address ,string  city , string zipcode ,string  phone ,string  cellphone )
    {
        try
        {
            //string firstname = "", lastname = "", address = "", city = "", zipcode = "", phone = "", cellphone = "";

            MembershipCreateStatus _status;

            bool bln = Membership.DeleteUser(username);
            //bln = Roles.DeleteRole(username);

            string user_name = username;
            //string email = "*****@*****.**";
            //string password = "******";
            string question = null;
            string answer = null;

            MembershipUser user = Membership.CreateUser
            (
                user_name,
                password,
                email,
                question,
                answer,
                true,
                out _status
            );

            Roles.AddUserToRoles(user.UserName, new string[] { "Member" });

            ProfileCommon profile = new ProfileCommon();

            profile = profile.GetProfile(user.UserName);

            //ProfileCommon profile = Profile.GetProfile(user.UserName);

            profile.FirstName = firstname;
            profile.LastName = lastname;
            profile.DateOfBirth = Convert.ToDateTime("1/1/1900");
            profile.Sex = System.DBNull.Value.ToString();
            profile.ShippingZipCode = zipcode;
            profile.ShippingAddress1 = address;
            profile.ShippingCity = city;
            profile.WorkPhone = phone;
            profile.Browser = HttpContext.Current.Request.Browser.Browser + " " +
                HttpContext.Current.Request.Browser.MajorVersion;
            profile.IPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
            profile.LanguageCode = HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"].ToString();
            profile.Timezone = TimeZone.CurrentTimeZone.StandardName.ToString();

            profile.Save();

            Subscriber subscriberInfo = new Subscriber();
            subscriberInfo.FirstName = firstname;
            subscriberInfo.LastName = lastname;
            subscriberInfo.Email = email;
            subscriberInfo.SubscribedStatus = true;
            subscriberInfo.TotalEmailsSent = 0;
            Subscriber.ManageSubscription(subscriberInfo);
            
            return true;
        }
        catch (Exception ex)
        {
            return false;
        }
    }
        /// <summary>
        /// get profile for particular group and user
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="groupName"></param>
        /// <returns>return a dictionary object that holds "property_name" as a key and "property_value" as a value</returns>
        public Dictionary<string, object> GetProfileByUserGroup(string userName,string groupName)
        {
            ProfileCommon pc = new ProfileCommon();
            ProfileCommon existing_pc = pc.GetProfile(userName);

            return (Dictionary<string,object>)existing_pc.GetProfileGroup(groupName).GetPropertyValue("properties_block");
        }
        /// <summary>
        /// get profile with metioned properties for particular group and user
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="groupName"></param>
        /// <returns>return a dictionary object that holds "property_name" as a key and "property_value" as a value</returns>
        public Dictionary<string, object> GetProfileByUserGroup(string userName,string groupName,ArrayList propertyNameList)
        {
            Dictionary<string, object> selectedPropertiesDictionary = new Dictionary<string,object>();
            ProfileCommon pc = new ProfileCommon();
            ProfileCommon existing_pc = pc.GetProfile(userName);

            Dictionary<string,object> profileDictionary = (Dictionary<string,object>)existing_pc.GetProfileGroup(groupName).GetPropertyValue("properties_block");

            if(profileDictionary.Keys.Count > 0)
            {
                propertyDepth = "";
                selectedPropertiesDictionary = FindProperties(profileDictionary,selectedPropertiesDictionary,propertyNameList);
            }

            return selectedPropertiesDictionary;
        }