Exemplo n.º 1
0
        public async Task <bool> Signup(SignUpAC signupAC)
        {
            using (IDbConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                try
                {
                    connection.Open();
                    var id            = Guid.NewGuid();
                    var password      = PasswordHashUtill.HashPassword(signupAC.Password);
                    var securityStamp = Guid.NewGuid();

                    var insertQuery = "INSERT INTO AspNetUsers values ('" + id + "','" + signupAC.Email + "',0,'" + password + "','" + securityStamp + "',null,0,0,null,1,0,'" + signupAC.Email + "');";
                    await connection.ExecuteScalarAsync(insertQuery);

                    var newUserQuery = "select MAX(Id) from AspNetUsers";
                    var newUserId    = await connection.ExecuteScalarAsync <string>(newUserQuery);

                    var userRoleQuery = "Insert into AspNetUserRoles values('" + newUserId + "',1)";
                    await connection.ExecuteScalarAsync(userRoleQuery);

                    return(true);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is use for new user signup
        /// </summary>
        /// <param name="userDetailDTO"></param>
        /// <returns></returns>
        public async Task <BaseResponse> SignUpAsync(UserDetailDTO userDetailDTO)
        {
            try
            {
                //string ConnectionString = _config[_iStringConstants.MyConnectionString];
                BaseResponse baseResponse = new BaseResponse();
                UserTokenDTO userTokenAC  = new UserTokenDTO();
                using (DeepakdbContext deepakDBContext = new DeepakdbContext())
                {
                    //deepakDBContext.Query<T>().AsTracking().
                    var data = await Task.Run(() => deepakDBContext
                                              .Database.ExecuteSqlRaw("spInsertUserDetail @FirstName=@p0, @LastName=@p1,@Email=@p2,@Password=@p3,@MobileNumber=@p4,@Address_Line1=@p5,@Address_Line2=@p6, @ZipCode=@p7, @CreatedBy=@p8",
                                                                      parameters: new [] { userDetailDTO.FirstName, userDetailDTO.LastName, userDetailDTO.Email,
                                                                                           PasswordHashUtill.HashPassword(userDetailDTO.Password), userDetailDTO.MobileNumber,
                                                                                           userDetailDTO.AddressLine1, userDetailDTO.AddressLine2, userDetailDTO.ZipCode.ToString(),
                                                                                           userDetailDTO.CreatedBy }



                                                                      /*new SqlParameter("@FirstName", userDetailDTO.FirstName),
                                                                       * new SqlParameter("@LastName", userDetailDTO.FirstName),
                                                                       * new SqlParameter("@Email", userDetailDTO.Email),
                                                                       * new SqlParameter("@Password",PasswordHashUtill.HashPassword( userDetailDTO.Password)),
                                                                       * new SqlParameter("@MobileNumber", userDetailDTO.MobileNumber),
                                                                       * new SqlParameter("@Address_Line1", userDetailDTO.AddressLine1),
                                                                       * new SqlParameter("@Address_Line2", userDetailDTO.AddressLine2),
                                                                       * new SqlParameter("@ZipCode", userDetailDTO.ZipCode),
                                                                       * new SqlParameter("@CreatedBy", userDetailDTO.CreatedBy)*/
                                                                      ));

                    if (data != null)
                    {
                        baseResponse.StatusCode = 1;
                        baseResponse.Message    = _iStringConstants.AddedSuccessfully;
                        // Need to ask how to get DBCONTEXT status code from store procedure
                    }
                    if (baseResponse.StatusCode == 1)
                    {
                        return(StatusBuilder.ResponseSuccessStatus(null, baseResponse.Message));
                    }

                    return(StatusBuilder.ResponseFailStatus(null, baseResponse.Message));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }