Пример #1
0
 internal static IList <CATEGORY> FindCatsParentList()
 {
     using (IDalSearch dal = new DalSearch())
     {
         return(dal.GetAllCats());
     }
 }
Пример #2
0
 internal static IList <AGE> FindAgesList()
 {
     using (IDalSearch dal = new DalSearch())
     {
         return(dal.GetAllAges());
     }
 }
Пример #3
0
 internal static IList <HERO> FindHerosList()
 {
     using (IDalSearch dal = new DalSearch())
     {
         return(dal.GetAllHeros());
     }
 }
Пример #4
0
 internal static IList <BRAND> FindBrandsList()
 {
     using (IDalSearch dal = new DalSearch())
     {
         return(dal.GetAllBrands());
     }
 }
Пример #5
0
 internal static IList <SPP_ParentCategoriesTransDistinct_Result> FindCatsParentList(string language)
 {
     using (IDalSearch dal = new DalSearch())
     {
         int lang = LanguageBL.FindIdLanguageByShortForm(language);
         return(dal.GetAllCats(lang));
     }
 }
Пример #6
0
 internal static IList <PRODUCT> FindProductListByIdCat(string argument)
 {
     using (IDalSearch dal = new DalSearch())
     {
         int id = int.Parse(argument);
         return(dal.GetAllProductByIdCat(id));
     }
 }
Пример #7
0
 internal static IList <SPP_ProductTrans_Result> FindProductListByIdCat(string argument, string language)
 {
     using (IDalSearch dal = new DalSearch())
     {
         int id   = int.Parse(argument);
         int lang = LanguageBL.FindIdLanguageByShortForm(language);
         return(dal.GetAllProductByIdCat(id, lang));
     }
 }
Пример #8
0
 internal static IList <SPP_ChildCategoriesOfParent_Result> FindCatsChildList(string argument, string language)
 {
     using (IDalSearch dal = new DalSearch())
     {
         int id   = int.Parse(argument);
         int lang = LanguageBL.FindIdLanguageByShortForm(language);
         return(dal.GetAllCats(id, lang));
     }
 }
        public IEnumerable <DalTextDescription> Search(DalSearch model)
        {
            if (model == null)
            {
                throw new NullReferenceException(nameof(model));
            }
            if (model.MinRating != null && model.MinRating < 0 || model.MinRating > 5)
            {
                throw new ArgumentException(nameof(model.MinRating));
            }
            if (model.MaxRating != null && model.MaxRating < 0 || model.MaxRating > 5)
            {
                throw new ArgumentException(nameof(model.MaxRating));
            }
            if (model.MaxRating != null && model.MaxRating != null && model.MinRating > model.MaxRating)
            {
                throw new ArgumentException(nameof(model.MaxRating));
            }
            var result = context.TextDescription.Where(td => td.IsPublished);

            if (model.Title != null && model.Title.Trim() != String.Empty)
            {
                if (model.SearchSubtitles)
                {
                    result =
                        result.Where(
                            td =>
                            td.Title.ToLower().Contains(model.Title.Trim().ToLower()) ||
                            td.Text.Any(text => text.Subtitle.ToLower().Contains(model.Title.Trim().ToLower())));
                }
                else
                {
                    result = result.Where(td => td.Title.ToLower().Contains(model.Title.Trim().ToLower()));
                }
            }
            if (model.PublisherLogin != null && model.PublisherLogin.Trim() != String.Empty)
            {
                result = result.Where(td => td.User.Login.ToLower().Contains(model.PublisherLogin.ToLower()));
            }
            if (model.PublicationDateStart != null)
            {
                result =
                    result.Where(td => td.PublicationDate > model.PublicationDateStart);
            }
            if (model.PublicationDateFinish != null)
            {
                result = result.Where(td => td.PublicationDate < model.PublicationDateFinish);
            }
            if (model.MinRating != null && model.MinRating != 0)
            {
                model.IncludeUnrated = false;
            }
            if (model.MinRating != null)
            {
                result = result.Where(td => td.Rating.Select(r => r.value).DefaultIfEmpty().Average() >= model.MinRating);
            }
            if (model.MaxRating != null)
            {
                result = result.Where(td => td.Rating.Select(r => r.value).DefaultIfEmpty().Average() <= model.MaxRating);
            }
            if (!model.IncludeUnrated)
            {
                result = result.Where(td => td.Rating.Count != 0);
            }
            return(result.Select(Mapper.ToDal));
        }