Exemple #1
0
        public ActionResult ChangeDisplayName(Entities.Models.Profile.ChangeDisplayName model)
        {
            if (ModelState.IsValid)
            {
                int    currentUserId      = Authentication.Security.CurrentUserId;
                String currentDisplayName = Authentication.Security.CurrentUserName;

                Entities.OAMembership memberShipData = null;

                if (!Authentication.Security.UserExists(model.DisplayName))
                {
                    memberShipData = _updateUser.Execute(currentUserId, model.DisplayName, currentDisplayName);
                }

                if (memberShipData != null)
                {
                    Authentication.Security.Logout();
                    Authentication.OAuthSecurity.Login(memberShipData.Provider, memberShipData.ProviderUserId, false);
                    return(Redirect(string.Format("/Profile/{0}", currentUserId)));
                }
                else if (model.DisplayName == currentDisplayName)
                {
                    return(Redirect(string.Format("/Profile/{0}", currentUserId)));
                }
                else
                {
                    ModelState.AddModelError("DisplayName", "Display name already exists. Please enter a different display name.");
                }
            }

            return(View(model));
        }
Exemple #2
0
        /// <summary>
        /// Update a user's display name based on <paramref name="filter"/>
        /// </summary>
        /// <param name="filter">Contains new and old display names</param>
        /// <returns></returns>
        public Entities.OAMembership Execute(Entities.Filters.User.UpdateDisplayName filter)
        {
            Entities.OAMembership membershipData = null;

            using (DbCommand cmd = _db.GetStoredProcCommand("User_UpdateDisplayName"))
            {
                _db.AddInParameter(cmd, "@UserId", DbType.Int32, filter.UserId);
                _db.AddInParameter(cmd, "@NewDisplayName", DbType.String, filter.NewDisplayName);
                _db.AddInParameter(cmd, "@OldDisplayName", DbType.String, filter.OldDisplayName);

                using (IDataReader idr = _db.ExecuteReader(cmd))
                {
                    while (idr.Read())
                    {
                        membershipData = new Entities.OAMembership(idr);
                    }
                }
            }

            return(membershipData);
        }
Exemple #3
0
		/// <summary>
		/// Update a user's display name based on <paramref name="filter"/>
		/// </summary>
		/// <param name="filter">Contains new and old display names</param>
		/// <returns></returns>
		public Entities.OAMembership Execute(Entities.Filters.User.UpdateDisplayName filter)
		{
			Entities.OAMembership membershipData = null;

			using (DbCommand cmd = _db.GetStoredProcCommand("User_UpdateDisplayName"))
			{
				_db.AddInParameter(cmd, "@UserId", DbType.Int32, filter.UserId);
				_db.AddInParameter(cmd, "@NewDisplayName", DbType.String, filter.NewDisplayName);
				_db.AddInParameter(cmd, "@OldDisplayName", DbType.String, filter.OldDisplayName);

				using (IDataReader idr = _db.ExecuteReader(cmd))
				{
					while (idr.Read())
					{
						membershipData = new Entities.OAMembership(idr);
					}
				}
			}

			return membershipData;
		}