Exemple #1
0
        public IEnumerable <User> GetAllValidUsers(TimeCategories time = TimeCategories.All)
        {
            var listUsers = GetAllValidUsers();

            if (time == TimeCategories.All)
            {
                return(new List <User>(listUsers));
            }

            var aFunction = TimeFilterManager.GetTimeFilterDateComparison(time);

            return
                ((from user in listUsers.ToArray()
                  let timeCreate = user.AppUser.DateCreated
                                   where aFunction(timeCreate)
                                   select user).ToArray());
        }
Exemple #2
0
        public IEnumerable <OwnerInvitationModel> GetInvitations(IEnumerable <Invitation> invitationList, TimeCategories time)
        {
            if (time == TimeCategories.All)
            {
                return(invitationList.Select(this.DbToModel));
            }

            var aFunction       = TimeFilterManager.GetTimeFilterDateComparison(time);
            var invitationsTime = new List <OwnerInvitationModel>();

            if (aFunction != null)
            {
                invitationsTime.AddRange(
                    from invitation in invitationList.ToList()
                    let timeDataSent = invitation.DateSent
                                       where aFunction(timeDataSent)
                                       select this.DbToModel(invitation));
            }
            return(invitationsTime);
        }
Exemple #3
0
        /// <summary>
        /// Gets item registrations with tags matching the given criteria and time category
        /// </summary>
        /// <param name="criteria"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public IEnumerable <Lok.Unik.ModelCommon.ItemRegistration.ItemRegistration> Get(string criteria = null, TimeCategories time = TimeCategories.All)
        {
            var filteredItemRegistrationList = new List <Lok.Unik.ModelCommon.ItemRegistration.ItemRegistration>();

            using (var session = DocumentStoreLocator.ResolveOrRoot(CommonConfiguration.CoreDatabaseRoute))
            {
                var tenancy = ContextRegistry.ContextsOf("Tenancy").First().Segments[1];
                if (!string.IsNullOrEmpty(criteria))
                {
                    var query = from entity in session.Query <Lok.Unik.ModelCommon.ItemRegistration.ItemRegistration>()
                                where
                                entity.TenancyId == tenancy && entity.Tags.Any(tag => tag.Id.ToString() == criteria)
                                select entity;

                    filteredItemRegistrationList.AddRange(query);
                }

                //filter by criteria over registered time
                if (time != TimeCategories.All)
                {
                    var registrations = from entity in session.Query <Lok.Unik.ModelCommon.ItemRegistration.ItemRegistration>()
                                        where entity.TenancyId == tenancy
                                        select entity;

                    var aFunction = TimeFilterManager.GetTimeFilterDateComparison(time);

                    return((from itemRegistration in registrations.ToArray()
                            let dateCreation = itemRegistration.TimeRegistered
                                               where aFunction(dateCreation)
                                               select itemRegistration).ToArray());
                }

                if (string.IsNullOrEmpty(criteria) && time == TimeCategories.All)
                {
                    return(GetAll(session));
                }
            }

            return(filteredItemRegistrationList);
        }