public static async Task <ClaimsIdentity> GenerateUserIdentityAsync( this SalonUser user, UserManager <SalonUser, Guid> manager) { // Note the authenticationType must match the one defined in // CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here return(userIdentity); }
public async Task <int> AddSalonUser(SalonUser salonUser) { var retVal = 0; using (IDbConnection conn = Connection) { DynamicParameters _params = new DynamicParameters(); _params.Add("@UserName", salonUser.UserName, DbType.String, direction: ParameterDirection.Input, 50); _params.Add("@UserPwd", salonUser.UserPwd, DbType.String, direction: ParameterDirection.Input, 50); _params.Add("@UserFirstName", salonUser.UserFirstName, DbType.String, direction: ParameterDirection.Input, 50); _params.Add("@SalonUserId", DbType.Int32, direction: ParameterDirection.Output); var result = await conn.ExecuteAsync("[dbo].AddSalonUser", _params, null, null, CommandType.StoredProcedure).ConfigureAwait(false); retVal = _params.Get <int>("SalonUserId"); } return(retVal); }
public static void ValidateApplicationUser( this IFeelGoodSalonIdentityContext dbContext, DbEntityValidationResult result) { var entity = result.Entry.Entity as SalonUser; if (entity == null) { return; } SalonUser temp = dbContext .Users.FirstOrDefault(x => x.UserName == entity.UserName); if ((temp != null) && (temp.Id != entity.Id)) { result.ValidationErrors.Add( new DbValidationError( // A {0} with the {1} of '{2}' is already registered ({3}) "UserName", String.Format("An user with user-name {0} is already registered.", entity.UserName))); } }
public async Task <ActionResult <int> > AddSalonUser([FromBody] SalonUser salonUser) { return(await _salonUsersQueueRepo.AddSalonUser(salonUser)); }