Esempio n. 1
0
        public static CFBR_Validation_Response BookClientClass(CFBR_User cf_user, int cf_class_id)
        {
            ///////////////////////
            // Standard API call //
            ///////////////////////

            // Create Service
            ClassService classService = new ClassService();

            // Create request
            AddClientsToClassesRequest request = new AddClientsToClassesRequest();

            // Create and fill credentials
            request.SourceCredentials = new SourceCredentials();
            request.SourceCredentials.SourceName = SOURCE_NAME;
            request.SourceCredentials.Password = SOURCE_PASSWORD;
            request.SourceCredentials.SiteIDs = SITE_IDS;

            string[] client_ids = { cf_user.ClientId }; // Add User ID
            request.ClientIDs = client_ids;

            int[] class_ids = { cf_class_id }; // Add Class ID
            request.ClassIDs = class_ids;

            request.RequirePayment = false;

            request.Test = false;

            // Run call with request and fill result
            AddClientsToClassesResult api_result = classService.AddClientsToClasses(request);

            CFBR_Validation_Response result = new CFBR_Validation_Response();

            result.DataObj = api_result;
            result.IsValid = (api_result.Status == StatusCode.Success);
            result.Message = api_result.Message;

            return result;
        }
Esempio n. 2
0
        public static CFBR_Validation_Response LoginClient(string username, string password)
        {
            ClientService service = new ClientService();

            // Create request
            ValidateLoginRequest request = new ValidateLoginRequest();

            // Create and fill credentials
            request.SourceCredentials = new SourceCredentials();
            request.SourceCredentials.SourceName = SOURCE_NAME;
            request.SourceCredentials.Password = SOURCE_PASSWORD;
            request.SourceCredentials.SiteIDs = SITE_IDS;

            request.Username = username;
            request.Password = password;

            ValidateLoginResult api_result = service.ValidateLogin(request);

            CFBR_Validation_Response result = new CFBR_Validation_Response();

            if (api_result.Status == StatusCode.Success)
            {
                result.IsValid = true;
                result.DataObj = new CFBR_User()
                {
                    ClientId = api_result.Client.ID,
                    Username = api_result.Client.Email,
                    SessionGuid = api_result.GUID
                };
                result.Message = "SUCCESS";
            }
            else {
                result.IsValid = false;
                result.Message = "Error logging in";
            }

            return result;
        }