示例#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));
        }