Пример #1
0
    public static void OrderEntryService(S4DSAuthenticationInformation info, int packages)
    {
        var requestParams = new NVPStringBuilder()
                            .Append("personId", info.personId)
                            .Append("token", info.token)
                            .Append("productSKU", "99999997FG00000")
                            .Append("quantity", packages)
                            .Append("catalogId", 2)
                            .Build();

        var jsonResponse = S4DSAPI.SendRequest("rest/OrderEntryServices", requestParams);
    }
Пример #2
0
    public static int GetMemberPackages(string personId, string token)
    {
        try
        {
            var requestParams = new NVPStringBuilder()
                                .Append("personId", personId)
                                .Append("token", token)
                                .Build();

            var jsonResponse = S4DSAPI.SendRequest("ConsultarAsesor", requestParams);

            return(Convert.ToInt32(jsonResponse["points"].ToString()));
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex);
            return(0);
        }
    }
Пример #3
0
    public static Member GetMember(MemberAuthenticationData authData)
    {
        var requestParams = new NVPStringBuilder()
                            .Append("operation", "login")
                            .Append("username", authData.Username)
                            .Append("password", authData.PrimaryPassword)
                            .Append("domain", "WS_INTEGRATION_ACCESS")
                            .Build();

        var          jsonResponse = S4DSAPI.SendRequest("rest/AuthService", requestParams);
        S4DSAuthInfo AuthInfo     = new S4DSAuthInfo(jsonResponse);

        if (!AuthInfo.IsOK)
        {
            throw new MsgException("Unable to log in using those credentials.");
        }

        if (!Member.Exists(authData.Username))
        {
            //Register
            TitanRegisterService.Register(authData.Username, authData.Username, 1234,
                                          new DateTime(1980, 1, 1), authData.PrimaryPassword, String.Empty, Gender.Male, null, String.Empty,
                                          String.Empty, String.Empty, String.Empty, String.Empty, String.Empty, true, false, false, null, true);
        }

        Member Result = new Member(authData.Username);

        S4DSAuthenticationInformation.AddOrUpdate(Result.Id, AuthInfo);

        Result.S4DSPackages = GetMemberPackages(AuthInfo);
        Result.SaveCustomFeatures();

        //if (Result.S4DSPackages == 0)
        //    throw new MsgException("You cannot login because you have 0 packages.");

        return(Result);
    }