public async Task <SaveStatus> RegisterUser(RegisterIDTO objRegister)
        {
            try
            {
                using (IDbConnection conn = Connection)
                {
                    var param = new DynamicParameters();
                    param.Add("@FirstName", objRegister.FirstName, DbType.String, direction: ParameterDirection.Input);
                    param.Add("@LastName", objRegister.LastName, DbType.String, direction: ParameterDirection.Input);
                    param.Add("@Email", objRegister.loginDetails.Email, DbType.String, direction: ParameterDirection.Input);
                    param.Add("@Password", EncodeDecodeBase64.Base64Encode(objRegister.loginDetails.Password), DbType.String, direction: ParameterDirection.Input);
                    param.Add("@ReturnValue", DbType.Int32, direction: ParameterDirection.ReturnValue);


                    await conn.ExecuteAsync("usp_RegisterUser", param, commandType : CommandType.StoredProcedure);

                    var        retValue = param.Get <int>("@ReturnValue");
                    SaveStatus status   = (SaveStatus)retValue;
                    return(status);
                }
            }
            catch (Exception e)
            {
                return(SaveStatus.Failure);
            }
        }
Exemple #2
0
        public async Task <IActionResult> Register([FromBody] RegisterIDTO registerInput)
        {
            SaveStatus status = await _registerRepo.RegisterUser(registerInput);

            switch (status)
            {
            case SaveStatus.Success:
                return(Ok());

            case SaveStatus.AlreadyExists:
                return(Conflict());

            case SaveStatus.Failure:
                return(StatusCode(500));

            default:
                return(StatusCode(500));
            }
        }