Esempio n. 1
0
        /// <summary>
        /// Get the activites list.
        /// </summary>
        /// <returns></returns>
        public async Task <ActivityViewData> FindActivity(int idActivity)
        {
            ActivityViewData activityViewData = new ActivityViewData
            {
                TranslationsList = new List <ActivityTranslationItemData>(),
                Activity         = new ActivityItemData()
            };
            ActivityRequestData findActivityRequest = new ActivityRequestData
            {
                ActivityDto = new ActivityItemData {
                    ActivityId = idActivity
                },
                FindActivityDto = FindActivityItemData.ActivityId
            };
            ActivityResultData resultActivity = await WebApiClient.PostFormJsonAsync <ActivityRequestData, ActivityResultData>(Constant.WebApiControllerActivities, Constant.WebApiFindActivities, findActivityRequest);

            if (resultActivity != null && resultActivity.OperationSuccess && resultActivity.ActivityDto != null)
            {
                activityViewData.Activity = resultActivity.ActivityDto;
                ActivityTranslationRequestData findActivityTranslationRequest = new ActivityTranslationRequestData()
                {
                    ActivityTranslationDto = new ActivityTranslationItemData {
                        ActivityId = idActivity
                    },
                    FindActivityTranslationDto = FindActivityTranslationItemData.ActivityId
                };
                ActivityTranslationResultData resultActivityTranslation = await WebApiClient.PostFormJsonAsync <ActivityTranslationRequestData, ActivityTranslationResultData>(Constant.WebApiControllerActivities, Constant.WebApiFindActivityTranslations, findActivityTranslationRequest);

                if (resultActivityTranslation != null && resultActivityTranslation.OperationSuccess && resultActivityTranslation.ActivityTranslationDtoList != null)
                {
                    activityViewData.TranslationsList.Add(resultActivityTranslation.ActivityTranslationDtoList.First(t => t.LanguageId == _lang));
                }
            }
            return(activityViewData);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the activites translations.
        /// </summary>
        /// <param name="activityId">the activite id.</param>
        /// <returns></returns>
        private async Task <List <ActivityTranslationItemData> > GetActivityTranslations(int activityId)
        {
            List <ActivityTranslationItemData> translationsList = new List <ActivityTranslationItemData>();
            ActivityTranslationRequestData     findActivityTranslationRequest = new ActivityTranslationRequestData()
            {
                ActivityTranslationDto = new ActivityTranslationItemData {
                    ActivityId = activityId
                },
                FindActivityTranslationDto = FindActivityTranslationItemData.ActivityId
            };
            ActivityTranslationResultData resultActivityTranslation = await WebApiClient.PostFormJsonAsync <ActivityTranslationRequestData, ActivityTranslationResultData>(Constant.WebApiControllerActivities, Constant.WebApiFindActivityTranslations, findActivityTranslationRequest);

            if (resultActivityTranslation != null && resultActivityTranslation.OperationSuccess && resultActivityTranslation.ActivityTranslationDtoList != null)
            {
                translationsList.AddRange(resultActivityTranslation.ActivityTranslationDtoList.Where(c => c.LanguageId == _lang).ToList());
            }
            return(translationsList);
        }