コード例 #1
0
ファイル: ItemRepository.cs プロジェクト: raulves/RentingApp
        public virtual async Task <IEnumerable <ItemView> > GetItemsForViewAsync(Guid?categoryId, string?search)
        {
            var items = RepoDbSet.AsNoTracking()
                        .Include(i => i.Images)
                        .Include(l => l.Location)
                        .Include(p => p.Prices).AsQueryable();

            if (!String.IsNullOrEmpty(search))
            {
                items = items
                        .Where(d =>
                               d.Description.ToLower().Contains(search.ToLower()) ||
                               d.Brand.ToLower().Contains(search.ToLower()) ||
                               d.Model.ToLower().Contains(search.ToLower()) ||
                               d.Location !.City.ToLower().Contains(search.ToLower()));
            }

            if (categoryId != Guid.Empty)
            {
                items = items
                        .Where(c => c.ItemCategories.Any(a => a.CategoryId == categoryId));
            }

            if (!String.IsNullOrEmpty(search) || categoryId != Guid.Empty)
            {
                return(await items
                       .Select(a => new ItemView()
                {
                    Id = a.Id,
                    Description = a.Description,
                    Image = a.Images.FirstOrDefault().Picture,
                    AddressLine = a.Location !.AddressLine,
                    Price = a.Prices.FirstOrDefault(p => p.RentalPeriod !.Description == "Päev").ItemPrice
                }).ToListAsync());
コード例 #2
0
 public async Task <DTO.BodyMeasurement> FindWithAppUserIdAsync(Guid id, Guid appUserId)
 {
     return(Mapper.MapDomainToDAL(
                await RepoDbSet
                .AsNoTracking()
                .FirstOrDefaultAsync(d => d.Id == id && d.AppUserId == appUserId)
                ));
 }
コード例 #3
0
 public override async Task <DTO.BodyMeasurement> FindAsync(Guid id)
 {
     return(Mapper.MapDomainToDAL(
                await RepoDbSet
                .AsNoTracking()
                .FirstOrDefaultAsync(d => d.Id == id)
                ));
 }
コード例 #4
0
 public override async Task <IEnumerable <DTO.DailyNutritionIntake> > AllAsync()
 {
     return((
                await RepoDbSet
                .AsNoTracking()
                .ToListAsync()
                ).Select(domainEntity => Mapper.MapDomainToDAL(domainEntity)));
 }
コード例 #5
0
        public string?GetLastInvoiceNumber()
        {
            var invoices = RepoDbSet.AsNoTracking().OrderByDescending(a => a.InvoiceNumber).ToListAsync();

            if (invoices.Result.Count == 0)
            {
                return(null);
            }
            return(invoices.Result.FirstOrDefault().InvoiceNumber);
        }
コード例 #6
0
 public async Task <IEnumerable <DTO.LangStr> > GetLanguageStrings()
 {
     return(await RepoDbSet.AsNoTracking()
            .Include(l => l.Translations)
            .Select(a => new DTO.LangStr()
     {
         Id = a.Id,
         CultureCount = a.Translations !.Count,
         CurrentValue = a
     })
コード例 #7
0
        public string?GetLastBookingNumber()
        {
            var bookings = RepoDbSet.AsNoTracking().OrderByDescending(a => a.BookingNumber).ToListAsync();

            if (bookings.Result.Count == 0)
            {
                return(null);
            }
            return(bookings.Result.FirstOrDefault().BookingNumber);
        }
コード例 #8
0
 public async Task <DTO.WorkoutRoutine> ActiveRoutineForUserWithIdAsync(Guid userId)
 {
     return(Mapper.MapDomainToDAL(
                await RepoDbSet
                .AsNoTracking()
                .Include(routine => routine.WorkoutRoutineInfos)
                .SingleOrDefaultAsync(
                    w => w.AppUserId.Equals(userId) &&
                    w.CreatedAt <= DateTime.Now &&
                    w.ClosedAt > DateTime.Now)
                ));
 }
コード例 #9
0
        public override async Task <DAL.App.DTO.Property> FirstOrDefaultAsync(Guid id, object?userId = null)
        {
            var query = (await RepoDbSet.AsNoTracking()
                         .Include(p => p.Reviews)
                         .Include(p => p.PropertyRules)
                         .Include(p => p.Extras)
                         .Include(property => property.PropertyRooms)
                         .ThenInclude(room => room.RoomFacilities)
                         .ThenInclude(rf => rf.Facility)
                         .FirstOrDefaultAsync(a => a.Id == id));

            return(Mapper.Map(query));
        }
コード例 #10
0
        public async Task <IEnumerable <DTO.ExerciseSet> > AllWithExerciseInTrainingDayIdAsync(
            Guid exerciseInTrainingDayId)
        {
            var domainObjects = await RepoDbSet
                                .AsNoTracking()
                                .Include(s => s.SetType)
                                .Include(s => s.UnitType)
                                .Where(s => s.ExerciseInTrainingDay.Id == exerciseInTrainingDayId)
                                .ToListAsync();

            var dalObjects = domainObjects.Select(Mapper.MapDomainToDAL);

            return(dalObjects);
        }
コード例 #11
0
        public override async Task <DTO.TrainingDay> FindAsync(Guid id)
        {
            var domainEntity = await RepoDbSet
                               .AsNoTracking()
                               .Include(d => d.TrainingDayType)
                               .Include(d => d.ExercisesInTrainingDay)
                               .ThenInclude(e => e.ExerciseSets)
                               .ThenInclude(s => s.SetType)
                               .Include(d => d.ExercisesInTrainingDay)
                               .ThenInclude(e => e.ExerciseType)
                               .Include(d => d.ExercisesInTrainingDay)
                               .ThenInclude(e => e.Exercise)
                               .FirstOrDefaultAsync(d => d.Id == id);

            var dalEntity = Mapper.MapDomainToDAL(domainEntity);

            return(dalEntity);
        }
コード例 #12
0
 public Guid GetRentalPeriodId(string period)
 {
     return(RepoDbSet.AsNoTracking().Single(d => d.Description.Equals(period)).Id);
 }
コード例 #13
0
 public async Task <DTO.DailyNutritionIntake> FindWithAppUserIdAsync(Guid id, Guid appUserId)
 {
     return(Mapper.MapDomainToDAL(await RepoDbSet
                                  .AsNoTracking()
                                  .SingleOrDefaultAsync(d => d.Id == id && d.AppUserId == appUserId)));
 }
コード例 #14
0
 public override async Task <DTO.DailyNutritionIntake> FindAsync(Guid id)
 {
     return(Mapper.MapDomainToDAL(await RepoDbSet
                                  .AsNoTracking()
                                  .SingleOrDefaultAsync(d => d.Id == id)));
 }