Пример #1
0
        public static string ConvertJobAlertViewModelToSearchModel(JobAlertViewModel model, List <JobAlertEditFilterRootItem> filtersVMList)
        {
            JobAlertEditFilterRootItem dest = new JobAlertEditFilterRootItem();

            if (model.SalaryStringify != null)
            {
                model.Salary = JsonConvert.DeserializeObject <JobAlertSalaryFilterReceiver>(model.SalaryStringify);
            }

            var alertViewModel = JsonConvert.SerializeObject(model);


            if (model.Filters != null && model.Filters.Count > 0)
            {
                foreach (var rootItem in model.Filters)
                {
                    if (rootItem != null)
                    {
                        if (filtersVMList != null && filtersVMList.Count > 0)
                        {
                            foreach (var filterVMRootItem in filtersVMList)
                            {
                                if (filterVMRootItem.Name == rootItem.RootId)
                                {
                                    if (filterVMRootItem.Filters != null && filterVMRootItem.Filters.Count > 0)
                                    {
                                        foreach (var filterItem in filterVMRootItem.Filters)
                                        {
                                            MergeFilters(filterItem, rootItem.Values);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            dynamic searchModel = new ExpandoObject();

            searchModel.search = _mapToSearchModel(filtersVMList, model);
            if (alertViewModel != null)
            {
                searchModel.jobAlertViewModelData = JsonConvert.DeserializeObject <JobAlertViewModel>(alertViewModel);
            }
            else
            {
                searchModel.jobAlertViewModelData = null;
            }

            return(JsonConvert.SerializeObject(searchModel));
        }
Пример #2
0
        private static dynamic _mapToClassificationData(JobAlertEditFilterRootItem filter, JobAlertViewModel model)
        {
            if (filter.Name != null && filter.Name.ToLower() != SalaryString.ToLower())
            {
                dynamic classification = new ExpandoObject();
                classification.SearchType             = CategoryString;
                classification.ClassificationRootName = filter.Name;

                var subTargets = filter.Filters
                                 .Select(x => MapJobAlertFilterToClassification(x))
                                 .Where(x => x != null)
                                 .ToList();
                if (subTargets != null && subTargets.Count > 0)
                {
                    classification.TargetClassifications = subTargets;
                    return(classification);
                }
            }

            return(null);
        }