Esempio n. 1
0
        public async Task <List <DateTime> > DatesList(Guid?userId = null)
        {
            var personId = RepoDbContext.Persons.First(p => p.AppUserId == userId).Id;

            return(await RepoDbSet.Where(o => o.ParentId == personId || o.ChildId == personId)
                   .Select(o => o.Time).Select(t => t !.StartTime).ToListAsync());
        }
        public async Task <IEnumerable <Notification> > AllImportant(Guid?userId = null)
        {
            var personId = RepoDbContext.Persons.First(p => p.AppUserId == userId).Id;

            return((await RepoDbSet.Where(n => n.RecipientId == personId)
                    .ToListAsync()).Select(dbEntity => Mapper.Map(dbEntity)));
        }
Esempio n. 3
0
        public async Task <IEnumerable <Location> > AllForPerson(Guid?userId = null)
        {
            var personId = RepoDbContext.Persons.First(p => p.AppUserId == userId).Id;

            return((await RepoDbSet.Where(l => l.PersonId == personId).ToListAsync())
                   .Select(dbEntity => Mapper.Map(dbEntity)));
        }
Esempio n. 4
0
        public async Task <IEnumerable <DTO.Review> > PropertyReviews(Guid?propertyId)
        {
            var query = RepoDbSet.Where(a => a.PropertyId == propertyId)
                        .Include(r => r.AppUser).AsQueryable();

            return(await query.Select(entity => Mapper.Map(entity)).ToListAsync());
        }
 public async Task <ICollection <DTO.Team> > AllAsync(Guid?userId = null)
 {
     if (userId == null)
     {
         return((await base.AllAsync()).ToList());; // base is not actually needed, using it for clarity
     }
     return((await RepoDbSet.Where(o => o.Id == userId).ToListAsync()).Select(domainEntity => Mapper.Map(domainEntity)).ToList());
 }
Esempio n. 6
0
 public async Task <IEnumerable <DAL.App.DTO.Identity.AppUser> > AllAsync(Guid?userId = null)
 {
     if (userId == null)
     {
         return(await AllAsync()); // base is not actually needed, using it for clarity
     }
     return((await RepoDbSet.Where(o => o.Id == userId).Include("PlayerPositions").ToListAsync()).Select(AccountMapper.Map));
 }
Esempio n. 7
0
        public async Task RemoveByProductId(int productId)
        {
            var objects = await RepoDbSet
                          .Where(obj => obj.ProductId == productId)
                          .ToListAsync();

            RepoDbSet.RemoveRange(objects);
        }
Esempio n. 8
0
 public async Task <Obligation> EditOne(Guid id)
 {
     return(Mapper.Map(await RepoDbSet.Where(o => o.Id == id)
                       .Include(o => o.Time)
                       .Include(o => o.Location)
                       .Include(o => o.Child)
                       .FirstOrDefaultAsync()));
 }
Esempio n. 9
0
        public async Task RemoveByChangeId(int changeId)
        {
            var objects = await RepoDbSet
                          .Where(obj => obj.ChangeId == changeId)
                          .ToListAsync();

            RepoDbSet.RemoveRange(objects);
        }
 public async Task <IEnumerable <DTO.Notification> > AllAsync(Guid?userId = null)
 {
     if (userId == null)
     {
         return(await base.AllAsync());
     }
     return((await RepoDbSet.Where(o => o.AppUserId == userId).ToListAsync()).Select(domainNotification => Mapper.Map(domainNotification)));
 }
        public async Task <IEnumerable <DTO.WorkoutRoutineInfo> > AllForWorkoutRoutineWithIdAsync(Guid routineId)
        {
            var routineInfos = await RepoDbSet
                               .Where(info => info.WorkoutRoutineId == routineId)
                               .ToListAsync();

            return(routineInfos.Select(Mapper.MapDomainToDAL));
        }
Esempio n. 12
0
 public async Task <List <DALOrganizationDTO> > AllMinDTOAsync()
 {
     return((await RepoDbSet
             .Where(organization => organization.IsDeleted == false)
             .ToListAsync())
            .Select(OrganizationMapper.FromDomain2)
            .ToList());
 }
        public override async Task <IEnumerable <DTO.RoutineType> > AllAsync()
        {
            var items = await RepoDbSet.Where(entity => entity.ParentTypeId == null)
                        .Include(entity => entity.SubTypes)
                        .ToListAsync();

            return(items.Select(Mapper.MapDomainToDAL));
        }
        public async Task <IEnumerable <DTO.TrainingPlace> > AllAsync(Guid?userId = null)
        {
            if (userId == null)
            {
                return(await base.AllAsync());
            }

            return((await RepoDbSet.Where(o => o.Id == userId).ToListAsync()).Select(domainEntity => Mapper.Map(domainEntity)));
        }
 public async Task <IEnumerable <DTO.DailyNutritionIntake> > AllWithAppUserIdAsync(Guid id)
 {
     return((
                await RepoDbSet
                .Where(b => b.AppUserId == id)
                .ToListAsync())
            .Select(domainEntity => Mapper.MapDomainToDAL(domainEntity)
                    ));
 }
        public async Task <IEnumerable <DTO.BodyMeasurement> > AllWithAppUserIdAsync(Guid id)
        {
            var items = await RepoDbSet
                        .Where(b => b.AppUserId.Equals(id))
                        .ToListAsync();

            var mappedItems = items.Select(Mapper.MapDomainToDAL);

            return(mappedItems);
        }
        public async Task <DTO.Team> FirstOrDefaultAsync(Guid?id, Guid?userId = null)
        {
            var query = RepoDbSet.Where(a => a.Id == id).AsQueryable();

            if (userId != null)
            {
                query = query.Where(a => a.Id == userId);
            }
            return(Mapper.Map(await query.FirstOrDefaultAsync()));
        }
Esempio n. 18
0
        public async Task <DAL.App.DTO.Policy> FirstOrDefaultAsync(Guid id, Guid?propertyId = null)
        {
            var query = RepoDbSet.Where(a => a.Id == id).AsQueryable();

            if (propertyId != null)
            {
                query = query.Where(a => a.PropertyId == propertyId);
            }
            return(Mapper.Map(await query.FirstOrDefaultAsync()));
        }
        public async Task <DTO.BodyMeasurement> LatestForUserWithIdAsync(Guid userId)
        {
            var measurements = await RepoDbSet
                               .Where(measurement => measurement.AppUserId == userId)
                               .ToListAsync();

            var last = measurements.OrderBy(measurement => measurement.LoggedAt).LastOrDefault();

            return(Mapper.MapDomainToDAL(last));
        }
Esempio n. 20
0
        public override async Task <IEnumerable <Warehouse> > AllAsync(object?userId = null, bool noTracking = true)
        {
            var query = (userId != null) ? RepoDbSet.Where(c => c.UserId == (Guid)userId) : RepoDbSet;
            //query.Include(w => w.WarehouseItems);
            var domainEntities = await query.AsNoTracking().ToListAsync();

            var result = domainEntities.Select(e => Mapper.Map(e));

            return(result);
        }
Esempio n. 21
0
        public async Task <DAL.App.DTO.Identity.AppUser> FirstOrDefaultAsync(Guid id, Guid?userId = null)
        {
            var query = RepoDbSet.Where(a => a.Id == id).Include("PlayerPositions").AsQueryable();

            if (userId != null)
            {
                query = query.Where(a => a.Id == userId);
            }

            return(AccountMapper.Map(await query.FirstOrDefaultAsync()));
        }
Esempio n. 22
0
        public override async Task <IEnumerable <BidDAL> > GetAllAsync()
        {
            // p.ItemEndDate.AddDays(BidsHistoryDays) > DateTime.Now &&
            var query = RepoDbSet
                        .Where(p => p.ItemEndDate <DateTime.Now && p.ItemEndDate.AddDays(BidsHistoryDays)> DateTime.Now)
                        .OrderBy(b => b.ItemName)
                        .ThenByDescending(b => b.BidAmount);
            var domainItems = await query.ToListAsync();

            var result = domainItems.Select(e => Mapper.Map(e));

            return(result);
        }
        public async Task <DTO.Training> FirstOrDefaultAsync(Guid?id, Guid?userId = null)
        {
            var query = RepoDbSet.Where(a => a.Id == id).AsQueryable();

            if (userId != null)
            {
                query = query.Where(a => a.Id == userId);
            }

            var training = await query.FirstOrDefaultAsync();

            return(TrainingMapper.Map(training));
        }
Esempio n. 24
0
        public override async Task <IEnumerable <Item> > AllAsync(object?userId = null, bool noTracking = true)
        {
            var query = (userId != null) ? RepoDbSet.Where(c => c.UserId == (Guid)userId) : RepoDbSet;

            query = query.Include(i => i.Brand)
                    .Include(i => i.ItemCategories)
                    .ThenInclude(ic => ic.Category);
            var domainEntities = await query.AsNoTracking().ToListAsync();

            var result = domainEntities.Select(e => Mapper.Map(e));

            return(result);
        }
Esempio n. 25
0
 public async Task <PersonDisplay> OnePerson(Guid?userId = null)
 {
     return(await RepoDbSet.Where(p => p.AppUserId == userId)
            .Select(dbEntity => new PersonDisplay()
     {
         Id = dbEntity.Id,
         AppUserId = dbEntity.AppUserId,
         FirstName = dbEntity.FirstName,
         LastName = dbEntity.LastName,
         Logo = dbEntity.Logo,
         FamilyId = dbEntity.FamilyId,
         PersonType = dbEntity.PersonType.ToString(),
         UnreadMessages = dbEntity.RecipientNotifications
                          .Where(n => n.Status == false) !.Count()
     })
Esempio n. 26
0
        public async Task EditAsync(DALPriceDTO priceDTO)
        {
            if ((priceDTO.ChangeId != null && priceDTO.ProductId != null) ||
                (priceDTO.ChangeId == null && priceDTO.ProductId == null))
            {
                throw new ArgumentException("Both priceId and product id can't be null or both can't have a value");
            }

            var time = priceDTO.ValidFrom;

            if (priceDTO.ProductId != null)
            {
                var oldPrice = await RepoDbSet
                               .Where(price => price.ValidTo > time && price.ValidFrom < time &&
                                      price.ProductId == priceDTO.ProductId)
                               .SingleOrDefaultAsync();

                oldPrice.ValidTo = time;
            }
            else
            {
                var oldPrice = await RepoDbSet
                               .Where(price => price.ValidTo > time && price.ValidFrom < time &&
                                      price.ChangeId == priceDTO.ChangeId)
                               .SingleOrDefaultAsync();

                oldPrice.ValidTo = time;
            }

            var newPrice = new Price()
            {
                Value     = priceDTO.Value,
                ChangeId  = priceDTO.ChangeId,
                ProductId = priceDTO.ProductId,
                ValidTo   = priceDTO.ValidTo,
                ValidFrom = priceDTO.ValidFrom
            };

            await RepoDbSet.AddAsync(newPrice);
        }
Esempio n. 27
0
 public async Task <bool> ExistsValue(string locationValue, Guid?userId = null)
 {
     return(await RepoDbSet.Where(l => l.PersonId == userId)
            .AnyAsync(l => l.LocationValue == locationValue));
 }
Esempio n. 28
0
 public async Task <List <int> > CategoryIdsAsync(int productId)
 {
     return(await RepoDbSet.Where(obj => obj.ProductId == productId).Select(obj => obj.CategoryId).ToListAsync());
 }
Esempio n. 29
0
        public async Task <IEnumerable <DTO.Extra> > AllAsync(Guid propertyId)
        {
            var query = await RepoDbSet.Where(extra => extra.PropertyId == propertyId).ToListAsync();

            return(query.Select(e => Mapper.Map(e)));
        }
Esempio n. 30
0
 public async Task <Location> LocationByValue(string locationValue, Guid?userId = null)
 {
     return(Mapper.Map(await RepoDbSet.Where(l => l.PersonId == userId)
                       .Where(l => l.LocationValue == locationValue).FirstOrDefaultAsync()));
 }