Пример #1
0
        private void EvaluateSearchOptions()
        {
            if (InformationCategories == null)
            {
                InformationCategories = new InformationCategory[0];
            }

            if (InformationTypes == null)
            {
                InformationTypes = new InformationType[0];
            }

            if (InformationCategories.Contains(InformationCategory.All))
            {
                InformationCategories = new[] { InformationCategory.All };
            }

            if (InformationTypes.Contains(InformationType.All))
            {
                InformationTypes = new[] { InformationType.All };
            }

            if (InformationCategories == null && InformationTypes == null ||
                InformationCategories != null && InformationTypes != null && !InformationTypes.Any() &&
                !InformationCategories.Any())
            {
                InformationCategories = new[]
                {
                    InformationCategory.All
                };
            }
        }
 protected AbstractInformationModel(InformationTypes type)
 {
     CreatedTime      = DateTime.Now;
     IsCommented      = true;
     IsPublished      = true;
     _informationType = type;
 }
Пример #3
0
        /// <summary>
        /// Provided wheres will be gathered
        /// </summary>
        /// <param name="informationType">Information type</param>
        /// <param name="where">Where statement</param>
        /// <returns>Returns this with wheres</returns>
        public IDeviceCollection Where(InformationType informationType, string where)
        {
            Setup(HasExecuted());
            Queries.Add(new Query(informationType, where));

            if (InformationTypes == null)
            {
                InformationTypes = new[] { informationType };
            }
            InformationTypes = InformationTypes.Concat(new[] { informationType }).Distinct().ToArray();

            return(this);
        }
        protected AbstractInformationModel(Information information)
        {
            Id = information.Id;
            _informationType = (InformationTypes)information.InformationTypeId;
            Title            = information.Title;
            CreatedTime      = information.CreatedTime;
            ShortDescription = information.ShortDescription;
            IsCommented      = information.IsCommented;
            IsPublished      = information.IsPublished;
            Photos           = information.Photos.Select(i => new PhotoModel(i)).ToList();
            var isUserAnAdmin = HttpContext.Current.User.IsAdmin();

            Comments = information.Comments.Where(i => isUserAnAdmin || !i.Deleted).Select(i => new CommentModel(i)).ToList();
        }
Пример #5
0
        /// <summary>
        /// Provided queries will be gathered
        /// </summary>
        /// <param name="queries">List of query object containing InformationType and a string with where statement</param>
        /// <returns>Returns this with queries</returns>
        public IDeviceCollection WithQueries(IEnumerable <Query> queries)
        {
            Setup(HasExecuted());
            Queries.AddRange(queries);

            foreach (var query in Queries)
            {
                if (InformationTypes == null)
                {
                    InformationTypes = new[] { query.InformationType };
                }
                InformationTypes = InformationTypes.Concat(new[] { query.InformationType }).Distinct().ToArray();
            }

            return(this);
        }
Пример #6
0
        private bool InformationTypeSelected(MemberInfo memberInfo)
        {
            if (InformationTypes != null)
            {
                if (InformationTypes.Contains(InformationType.All))
                {
                    return(true);
                }

                var typeName = memberInfo?.Name;
                var parsed   = Enum.TryParse(typeName, out InformationType informationType);
                return(parsed && InformationTypes.Contains(informationType));
            }

            return(false);
        }
Пример #7
0
        private bool IsDataFilesSelectedWithoutWhere(MemberInfo memberInfo)
        {
            if (InformationTypes != null || InformationCategories != null)
            {
                var typeName = memberInfo?.Name;
                var informationTypeParsed = Enum.TryParse(typeName, out InformationType informationType);

                if ((InformationTypes == null || !InformationTypes.Contains(InformationType.All) || !InformationTypes.Contains(InformationType.DataFiles)) ||
                    (InformationCategories == null || !InformationCategories.Contains(InformationCategory.DataFiles)) || !InformationCategories.Contains(InformationCategory.All))
                {
                    var shouldFetchDataFiles = informationTypeParsed && informationType != InformationType.DataFiles ||
                                               Queries.Any(x => x.InformationType == InformationType.DataFiles);
                    return(shouldFetchDataFiles);
                }
            }

            return(false);
        }
Пример #8
0
 public bool CanHandle(int informationType)
 {
     return(InformationTypes.ContainsInformationType(informationType));
 }