/// <summary>
        /// Gets the profile with the specified profile name.
        /// </summary>
        /// <param name="profileName">The name of the profile to load.</param>
        /// <returns>The profile or null if the profile name was not found.</returns>
        private Profile LoadProfile(string profileName)
        {
            ProfilesRequest profileRequest = new ProfilesRequest()
            {
                Language        = "EN",
                SecurityContext = this.securityContext,
                Type            = ProfileType.Static      // Only static profiles can be used for the subscriberimport.
            };

            try {
                ProfilesResponse profileResponse = this.serviceAgent.GetProfiles(profileRequest);

                if (profileResponse != null)
                {
                    // Search the profile with the given name.
                    return(profileResponse.Profiles.FirstOrDefault(p => p.Name.Equals(profileName)));
                }

                return(null);
            }
            catch (Exception ex) {
                // A error occured
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
Esempio n. 2
0
        public void TranslationProfileGetTest()
        {
            ProfilesResponse profileResponse = new ProfilesResponse();

            profileResponse = translationApi.TranslationProfileGet("en", "fr", null, null);
            Assert.IsNotNull(profileResponse.Profiles);
        }
Esempio n. 3
0
        public void TranslationProfileGetAsyncTest()
        {
            ProfilesResponse profileResponse = new ProfilesResponse();

            Task.Run(async() =>
            {
                profileResponse = await translationApi.TranslationProfileGetAsync("en", "fr", null, null);
            }).Wait();
            Assert.IsNotNull(profileResponse.Profiles);
        }
        public async Task <IHttpActionResult> UpdateProfilesAsync(ProfilesRequest request)
        {
            var response = new ProfilesResponse();

            await _profileService.UpdateProfilesAsync(request.ProfilesViewModel);

            response.StatusCode = (int)HttpStatusCode.OK;

            return(Ok(response));
        }
        public async Task <IHttpActionResult> InsertProfilesAsync(ProfilesRequest request)
        {
            var response = new ProfilesResponse();

            var accountId = Identity.ToAccountID();
            await _profileService.InsertProfilesAsync(request.ProfilesViewModel);

            response.StatusCode = (int)HttpStatusCode.OK;

            return(Ok(response));
        }
        public async Task <IHttpActionResult> GetCountNewProfilesAsync()
        {
            var response = new ProfilesResponse();

            var accountId        = Identity.ToAccountID();
            var countNewProfiles = await _profileService.GetCountNewProfilesAsync(accountId);

            response.CountNewProfiles = countNewProfiles;
            response.StatusCode       = (int)HttpStatusCode.OK;

            return(Ok(response));
        }
Esempio n. 7
0
        public ProfilesResponse GetProfilesByUser([FromBody] ProfileRequest request)
        {
            ProfilesResponse response    = new ProfilesResponse();
            MProfile         profile     = new MProfile();
            List <MProfile>  profiles    = new List <MProfile>();
            BaseRequest      baseRequest = new BaseRequest();

            try
            {
                /*METODO QUE VALIDA EL TOKEN DE APLICACIÓN*/
                if (!BAplication.ValidateAplicationToken(request.ApplicationToken))
                {
                    response.Code    = "2";
                    response.Message = Messages.ApplicationTokenNoAutorize;
                    return(response);
                }
                /*************FIN DEL METODO*************/

                profile.UserId = request.Profile.UserId;

                int Val = 0;

                profiles = BProfile.LisByUser(profile, ref Val);

                if (Val.Equals(0))
                {
                    response.Code    = "0"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = Messages.Success;
                }
                else if (Val.Equals(2))
                {
                    response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.ErrorObtainingReults, "Profiles");
                }
                else
                {
                    response.Code    = "1"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                    response.Message = String.Format(Messages.NotReults, "Profiles");
                }
            }
            catch (Exception ex)
            {
                response.Code    = "2"; //0=> Ëxito | 1=> Validación de Sistema | 2 => Error de Excepción
                response.Message = ex.Message;
            }

            response.Profiles = profiles.ToArray();

            return(response);
        }
        public IProfilesResponse GetProfiles()
        {
            IProfilesResponse AProfileResponse = new ProfilesResponse();

            try
            {
                AProfileResponse.Profiles = _ProfileConverter.Convert(GetJsonProfiles());
                AProfileResponse.Success  = true;
            }
            catch (Exception e)
            {
                AProfileResponse.Success = false;
            }

            return(AProfileResponse);
        }
        public async Task <IHttpActionResult> GetProfilesForSearchAsync(int profilesBatchSize)
        {
            var response = new ProfilesResponse();

            var accountId = Identity.ToAccountID();
            var profiles  = await _profileService.GetProfilesForSearchAsync(accountId, profilesBatchSize);

            var countProfilesInProcess = await _profileService.GetCountProfilesInProcessAsync(accountId);

            var countNewProfiles = await _profileService.GetCountNewProfilesAsync(accountId);

            response.ProfilesViewModel      = profiles;
            response.CountProfilesInProcess = countProfilesInProcess;
            response.CountNewProfiles       = countNewProfiles;
            response.StatusCode             = (int)HttpStatusCode.OK;

            return(Ok(response));
        }