Ejemplo n.º 1
0
        public JsonResult GetSavedFilter(int savedFilterId)
        {
            SavedFilter savedFilter = savedFilterRepository.Get(savedFilterId);
            SavedFilter temp        = new SavedFilter();

            if (savedFilter.Garment == NOCATEGORY)
            {
                temp.Garment = "0";
            }
            else
            {
                temp.Garment = categoryRepository.GetByDescription(savedFilter.Garment).Id.ToString();
            }

            if (savedFilter.Trend == NOTREND)
            {
                temp.Trend = "0";
            }
            else
            {
                temp.Trend = trendRepository.GetByName(savedFilter.Trend).Id.ToString();
            }

            if (savedFilter.Color != string.Empty)
            {
                foreach (string color in savedFilter.Color.Split(new [] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    temp.Color += colorRepository.GetByDescription(color).Id.ToString() + ",";
                }
                if (temp.Color.Length > 0)
                {
                    temp.Color = temp.Color.Substring(0, temp.Color.Length - 1);
                }
            }

            if (savedFilter.Pattern != string.Empty)
            {
                foreach (string pattern in savedFilter.Pattern.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
                {
                    temp.Pattern += patterRepository.GetByDescription(pattern).Id.ToString() + ",";
                }
                if (temp.Pattern.Length > 0)
                {
                    temp.Pattern = temp.Pattern.Substring(0, temp.Pattern.Length - 1);
                }
            }

            temp.CreatedByMe      = savedFilter.CreatedByMe;
            temp.IsRatedByFriends = savedFilter.IsRatedByFriends;
            temp.IsRatedByMe      = savedFilter.IsRatedByMe;
            temp.Name             = savedFilter.Name;
            temp.Search           = savedFilter.Search;
            temp.SeasonName       = savedFilter.SeasonName;
            temp.SelectedEvents   = savedFilter.SelectedEvents;
            temp.SelectedFlavors  = savedFilter.SelectedFlavors;
            temp.UserId           = savedFilter.UserId;
            temp.MyFavorites      = savedFilter.MyFavorites;
            temp.IsUpToDate       = savedFilter.IsUpToDate;

            return(Json(temp));
        }