예제 #1
0
        public static async Task <T> GetByIdFromCollection <T>(this Interfaces.IClientQueryRepository repository, string id) where T : Interfaces.IHaveId
        {
            var entities = await repository.Get <T>();

            if (entities == null)
            {
                return(default(T));
            }
            return(entities.FirstOrDefault(x => x.Id == id));
        }
        /// <summary>
        /// Sequential steps to build full client context
        /// </summary>
        public async Task Build(Context context, Interfaces.IClientQueryRepository repository)
        {
            _             = context ?? throw new ArgumentNullException("context");
            _             = repository ?? throw new ArgumentNullException("repository");
            context.Users = await repository.Get <Subjects.User>();

            context.Groups = await repository.Get <Subjects.Group>();

            context.Dates = await repository.Get <Date>();

            context.CalendarTypes = await repository.Get <CalendarType>();

            context.Calendars = await repository.Get <Calendar>();

            context.Events = await repository.Get <Event>();

            context.Comments = await repository.Get <Comment>();

            context.Occurences = await repository.Get <Occurence>();

            context.ReadRecords = await repository.Get <ReadRecord>();

            context.IsBuilt = true;
        }