Пример #1
0
        public async Task <IActionResult> Index()
        {
            IIncludableQueryable <Models.Task, Project> vPMDBContext = _context.Task.Include(t => t.Project);
            List <Models.Task> tasks = await vPMDBContext.ToListAsync();

            return(View(tasks));
        }
 public IIncludableQueryable <TEntity, TProperty> ThenInclude <TEntity, TPreviousProperty, TProperty>(
     IIncludableQueryable <TEntity, TPreviousProperty> source,
     Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath)
     where TEntity : class
 {
     return(new IncludableQueryable <TEntity, TProperty>(((Microsoft.EntityFrameworkCore.Query.IIncludableQueryable <TEntity, TPreviousProperty>)source).ThenInclude(navigationPropertyPath)));
 }
Пример #3
0
 private void AddMissingJoinedOnDates(IIncludableQueryable <Member, ICollection <Change> > members, ILogger log)
 {
     this.ChangeTracker.AutoDetectChangesEnabled = false;
     foreach (var m in members.ToArray().Where(x => x.JoinedOn == null && !x.HasLeft && x.Payments.Count() > 0).ToArray())
     {
         var ep = m.Payments.OrderBy(x => x.DueDate).FirstOrDefault().DueDate;
         if (ep != null)
         {
             m.JoinedOn = ep;
             var cr = new Change
             {
                 Date        = DateTimeOffset.Now,
                 MadeBy      = "System",
                 Member      = m,
                 Description = $"Joined on date {ep.ToDefault()} taken from payment record"
             };
             m.Changes.Add(cr);
             //this.SaveChanges();
             log.Information($"set member {m.Name} joining date to {ep.ToDefault()}");
         }
     }
     this.ChangeTracker.DetectChanges();
     this.SaveChanges();
     this.ChangeTracker.AutoDetectChangesEnabled = true;
 }
 public static IIncludableQueryable <TClass> Include <TClass, TProperty>(
     this IIncludableQueryable <TClass> includable,
     Expression <Func <TClass, TProperty> > expr,
     Expression <Func <TProperty, bool> > propertyFilter = null)
     where TClass : class
     where TProperty : class
 => includable.AddExpression(expr, propertyFilter);
Пример #5
0
        private void UpdatePaymentStatus(IIncludableQueryable <Member, ICollection <Change> > members, QParaOptions options, ILogger log)
        {
            this.ChangeTracker.AutoDetectChangesEnabled = false;
            var selectedMembers = members
                                  .Where(x => x.SubscriptionPeriod != SubscriptionPeriod.Life &&
                                         (x.SubscriptionType == SubscriptionType.Standard || x.SubscriptionType == SubscriptionType.Concession))
            ;
            var notSelectedMembers = members.Except(selectedMembers).Where(x => !x.GetIsPaid(options) /*!x.IsPaid*/);

            foreach (var m in notSelectedMembers.ToArray())
            {
                if (m.AmountDue != 0 || m.AmountReceived != 0)
                {
                    m.AmountDue = m.AmountReceived = 0;
                    log.Information($"{m.FirstName} {m.LastName} due and received amounts reset (to 0)");
                    //SaveChanges();
                }
            }
            var subscriptionYear = options.GetSubscriptionYear(DateTimeOffset.UtcNow);

            foreach (var m in selectedMembers.ToArray())
            {
                m.UpdatePaymentRecords(options, true);
                //SaveChanges();
            }
            ChangeTracker.DetectChanges();
            SaveChanges();
            this.ChangeTracker.AutoDetectChangesEnabled = true;
        }
Пример #6
0
        public IActionResult Filter(int?company, string name)
        {
            IIncludableQueryable <MetanitExampleCoreMVC.Models.User, Company> users = dbUsers.Users.Include(p => p.Company);
            IQueryable <MetanitExampleCoreMVC.Models.User> usersResult = null;

            if (company != null && company != 0)
            {
                usersResult = users.Where(p => p.CompanyId == company);
            }
            else
            {
                usersResult = users;
            }

            if (!String.IsNullOrEmpty(name))
            {
                usersResult = usersResult.Where(p => p.Name.Contains(name));
            }

            List <Company> companies = dbUsers.Companies.ToList();

            // устанавливаем начальный элемент, который позволит выбрать всех
            companies.Insert(0, new Company {
                Name = "Все", Id = 0
            });

            UsersListViewModel viewModel = new UsersListViewModel
            {
                Users     = usersResult?.ToList(),
                Companies = new SelectList(companies, "Id", "Name"),
                Name      = name
            };

            return(View(viewModel));
        }
Пример #7
0
        private void SearchByPrice(ref IIncludableQueryable <Product, ICollection <Color> > products, double?MinPrice, double?MaxPrice)
        {
            if (!products.Any())
            {
                return;
            }

            if (MinPrice == null && MaxPrice != null)
            {
                products = products.Where(c => c.price <= MaxPrice)
                           .Include(s => s.Sizes)
                           .Include(c => c.Colors);
            }
            else if (MinPrice != null && MaxPrice == null)
            {
                products = products.Where(c => c.price >= MinPrice)
                           .Include(s => s.Sizes)
                           .Include(c => c.Colors);
            }
            else if (MinPrice != null && MaxPrice != null)
            {
                products = products.Where(c => c.price >= MinPrice && c.price <= MaxPrice)
                           .Include(s => s.Sizes)
                           .Include(c => c.Colors);
            }
        }
Пример #8
0
 public static IIncludableQueryable<User, UserBuild> ThenIncludeEverything(this IIncludableQueryable<User, ICollection<User.UserGeneratedBuildOrder>> userBuilds)
 {
     return userBuilds
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.Processor)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.Motherboard)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.Memory)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.GraphicsCard)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.Storage)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.PowerSupply)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild)
         .ThenInclude(x => x.Case)
         .Include(x => x.UserGeneratedBuildOrders)
         .ThenInclude(x => x.UserGeneratedBuild);
 }
        public async Task <IActionResult> Index()
        {
            var user = await _userManager.GetUserAsync(HttpContext.User);

            var organizationsManagedByUser = _context.OrganizationAdministratorUsers
                                             .Where(x => x.User == user)
                                             .Select(x => x.OrganizationId)
                                             .ToList();

            IIncludableQueryable <Opportunity, Organization> opportunitiesQueryable = _context.Opportunities
                                                                                      .Include(o => o.Category)
                                                                                      .Include(o => o.CreatedBy)
                                                                                      .Include(o => o.Organization);

            List <Opportunity> opportunities = opportunitiesQueryable
                                               .Where(x => organizationsManagedByUser.Contains(x.Organization.Id))
                                               .OrderByDescending(x => x.Id)
                                               .ToList();

            return(View(opportunities
                        .Select(opportunity => new OpportunityIndexViewModel()
            {
                Id = opportunity.Id,
                CreatedDateTime = opportunity.CreatedDateTime,
                Name = opportunity.Name,
                Category = opportunity.Category?.Name,
                OpportunityType = opportunity.OpportunityType,
                IsArchived = opportunity.IsArchived
            })
                        .ToList()));
        }
 public BusinessIncludableQuery(
     BusinessQuery <TCollection, TReadOnlyCollection, TObject, TEntry, TKey> businessQuery,
     IIncludableQueryable <TEntry, TProperty> query
     ) : base(businessQuery.BusinessQueryContext, query)
 {
     _includableQueryable = query;
 }
 IncludeAvailabilityRestrictions(this IIncludableQueryable <ContractAccommodationRelation, SeasonRange> queryable,
                                 AvailabilityRequest availabilityRequest)
 => queryable.Include(relation => relation.Accommodation)
 .ThenInclude(accommodation => accommodation.Rooms)
 .ThenInclude(room => room.AvailabilityRestrictions.Where(availabilityRestrictions
                                                          => availabilityRequest.CheckInDate <= availabilityRestrictions.ToDate &&
                                                          availabilityRestrictions.FromDate <= availabilityRequest.CheckOutDate));
Пример #12
0
 public RecruiterService(DatabaseContext databaseContext)
 {
     _databaseContext = databaseContext;
     _recruitersIncludableGetQuery = _databaseContext.Recruiters
                                     .Include(x => x.Positions)
                                     .Include(x => x.ConversationData);
 }
Пример #13
0
 public static IIncludableQueryable <TEntity, TProperty> ThenIncluding <TEntity, TPreviousProperty, TProperty>(
     this IIncludableQueryable <TEntity, IEnumerable <TPreviousProperty> > source,
     Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath)
     where TEntity : class
 {
     return(System.Data.Entity.Include.QueryInclude.ThenInclude(source, navigationPropertyPath));
 }
Пример #14
0
        public async Task <IActionResult> Index()
        {
            ApplicationUser user = await GetCurrentUser();

            bool isAdmin = await IsAdmin(user);

            IIncludableQueryable <Opportunity, Organization> opportunitiesQueryable = _context.Opportunities
                                                                                      .Include(o => o.Category)
                                                                                      .Include(o => o.Community)
                                                                                      .Include(o => o.Organization);

            List <Opportunity> opportunities;

            if (isAdmin)
            {
                opportunities = await opportunitiesQueryable
                                .ToListAsync();
            }
            else
            {
                opportunities = await opportunitiesQueryable
                                .Where(o => o.CreatedByUserId == user.Id)
                                .ToListAsync();
            }

            return(View(opportunities));
        }
        // GET: ProjectUsers
        public async Task <IActionResult> Index( )
        {
            IIncludableQueryable <ProjectUser, HeimdallUser> applicationDbContext =
                this.context.ProjectUsers.Include(p => p.Project).Include(p => p.User);

            return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false)));
        }
Пример #16
0
 public static IIncludableQueryable <TEntity, TProperty> ThenInclude <TEntity, TPreviousProperty, TProperty>(
     this IIncludableQueryable <TEntity, IEnumerable <TPreviousProperty> > source,
     Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath)
     where TEntity : class
 {
     return(QueryableAdapter.ThenInclude(source, navigationPropertyPath));
 }
Пример #17
0
 private void SearchByCustomer(ref IIncludableQueryable <Order, Address> orders, int?customerId)
 {
     if (!orders.Any() || customerId == null)
     {
         return;
     }
     orders = orders.Where(o => o.customerId == customerId).Include(o => o.Address);
 }
Пример #18
0
 public void SearchByZip(ref IIncludableQueryable <Order, Address> orders, string zip)
 {
     if (!orders.Any() || string.IsNullOrEmpty(zip))
     {
         return;
     }
     orders = orders.Where(o => o.zip.Contains(zip.Trim())).Include(o => o.Address);
 }
Пример #19
0
 public void SearchByCountry(ref IIncludableQueryable <Order, Address> orders, string country)
 {
     if (!orders.Any() || string.IsNullOrEmpty(country))
     {
         return;
     }
     orders = orders.Where(o => o.country.Contains(country.Trim().ToLower())).Include(o => o.Address);
 }
Пример #20
0
        public void ShouldGetAllOfTheCarsWithMakes()
        {
            IIncludableQueryable <Car, Make?> query = Context.Cars.Include(c => c.MakeNavigation);
            var qs   = query.ToQueryString();
            var cars = query.ToList();

            Assert.Equal(9, cars.Count);
        }
Пример #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="guid"></param>
        /// <returns></returns>
        public static async Task <PatientJournal> GetPatientJournalById(this AerendeContext context, Guid guid)
        {
            IIncludableQueryable <PatientJournal, Adress> patientJournal = context.GetChildrenInQuery();

            var singelPatientJournal = patientJournal.SingleOrDefaultAsync(x => x.Id == guid);

            return(await singelPatientJournal);
        }
Пример #22
0
        public Task <Meal> FindAsync(int id)
        {
            var meal = new Meal();

            IIncludableQueryable <Meal, FoodItem> wackyEntity = context.Meals.Include(x => x.MealFoodItems).ThenInclude(x => x.FoodItems);

            throw new NotImplementedException();
        }
Пример #23
0
 public static IQueryable <TEntity> OptionalThenInclude <TEntity, TPreviousProperty, TProperty>(
     [NotNull] this IIncludableQueryable <TEntity, TPreviousProperty> source,
     [NotNull] Expression <Func <TPreviousProperty, TProperty> > navigationPropertyPath,
     bool performInclude)
     where TEntity : class
 {
     return(!performInclude ? (IQueryable <TEntity>)source : source.ThenInclude(navigationPropertyPath));
 }
Пример #24
0
        // GET: TicketAttachments
        public async Task <IActionResult> Index( )
        {
            IIncludableQueryable <TicketAttachment, HeimdallUser> applicationDbContext = this.context.TicketAttachments
                                                                                         .Include(t => t.Ticket)
                                                                                         .Include(t => t.User);

            return(this.View(await applicationDbContext.ToListAsync( ).ConfigureAwait(false)));
        }
Пример #25
0
 public void SearchByOrderNumber(ref IIncludableQueryable <Order, Address> orders, string orderNumber)
 {
     if (!orders.Any() || string.IsNullOrEmpty(orderNumber))
     {
         return;
     }
     orders = orders.Where(o => o.orderNumber.ToLower().Contains(orderNumber.Trim().ToLower()))
              .Include(o => o.Address);
 }
Пример #26
0
        private IIncludableQueryable <Event, object> GetInclude(IQueryable <Event> e)
        {
            IIncludableQueryable <Event, object> include = e
                                                           .Include(e => e.ActionDevice)
                                                           .Include(e => e.EventConditions)
                                                           .ThenInclude(ec => ec.DataPoint);

            return(include);
        }
Пример #27
0
 public static IIncludableQueryable <TEntity, TProperty> ThenIncludeMany <TEntity, TPreviousProperty, TProperty>(
     [NotNull] this IIncludableQueryable <TEntity, TPreviousProperty> source,
     Expression <Func <TPreviousProperty, IEnumerable <TProperty> > > navigationPropertyPath)
     where TEntity : class
 {
     return(source
            .ThenInclude(navigationPropertyPath)
            .ThenInclude <TEntity, TProperty, TProperty>(r => r));
 }
Пример #28
0
        public static IIncludableJoin <TEntity, TProperty> ThenIncludeJoin <TEntity, TPreviousProperty, TProperty>(
            this IIncludableJoin <TEntity, TPreviousProperty> query,
            Expression <Func <TPreviousProperty, TProperty> > propToExpand)
            where TEntity : class
        {
            IIncludableQueryable <TEntity, TPreviousProperty> queryable = ((IncludableJoin <TEntity, TPreviousProperty>)query).GetQuery();

            return(new IncludableJoin <TEntity, TProperty>(queryable.ThenInclude(propToExpand)));
        }
Пример #29
0
 public static IQueryable <T> If <T, P>(
     this IIncludableQueryable <T, IEnumerable <P> > source,
     bool condition,
     Func <IIncludableQueryable <T, IEnumerable <P> >, IQueryable <T> > transform
     )
     where T : class
 {
     return(condition ? transform(source) : source);
 }
Пример #30
0
 public void SearchByState(ref IIncludableQueryable <Order, Address> orders, string state)
 {
     if (!orders.Any() || string.IsNullOrEmpty(state))
     {
         return;
     }
     orders = orders.Where(o => o.state.Contains(state.Trim().ToLower()))
              .Include(o => o.Address);
 }