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; }
/// <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(); }
/// <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); }
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); }
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); }
public bool CanHandle(int informationType) { return(InformationTypes.ContainsInformationType(informationType)); }