public async Task <DALProductDTO> FindDTOAsync(int productId) { var product = await RepoDbSet .Include(p => p.ProductName) .ThenInclude(p => p.Translations) .Include(p => p.ProductDescription) .ThenInclude(desc => desc.Translations) .Include(p => p.ProductInCategories) .ThenInclude(obj => obj.Category) .ThenInclude(category => category.CategoryName) .ThenInclude(name => name.Translations) .Include(p => p.Prices) .Where(p => p.IsDeleted == false && p.Id == productId) .SingleOrDefaultAsync(); if (product == null) { return(null); } var currentPrice = PriceFinder.ForProduct(product, product.Prices, DateTime.Now); if (currentPrice == null) { return(null); } return(ProductMapper.FromDomain(product)); }
public async Task <DTO.TrainingCycle> GetFullActiveCycleForUserWithIdAsync(Guid userId) { var fullTrainingCycle = await RepoDbSet .Include(cycle => cycle.WorkoutRoutine) .Include(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays) .ThenInclude(day => day.TrainingDayType) .Include(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays) .ThenInclude(day => day.ExercisesInTrainingDay) .ThenInclude(exerciseInTrainingDay => exerciseInTrainingDay.ExerciseType) .Include(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays) .ThenInclude(day => day.ExercisesInTrainingDay) .ThenInclude(exerciseInTrainingDay => exerciseInTrainingDay.Exercise) .Include(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays).ThenInclude(day => day.ExercisesInTrainingDay) .ThenInclude(exerciseInTrainingDay => exerciseInTrainingDay.ExerciseSets) .ThenInclude(set => set.SetType) .OrderBy(cycle => cycle.StartingDate) .FirstOrDefaultAsync(cycle => cycle.WorkoutRoutine !.AppUserId == userId && cycle.CycleNumber == RepoDbSet.Max(c => c.CycleNumber)); var mappedCycle = Mapper.MapDomainToDAL(fullTrainingCycle); return(mappedCycle); }
public async Task <List <DALOrganizationDTO> > AllWithCategoriesAndProducts(DateTime time) { var o = await RepoDbSet .Include(organization => organization.Categories) .ThenInclude(category => category.CategoryName) .ThenInclude(name => name.Translations) .Include(organization => organization.Categories) .ThenInclude(category => category.ProductsInCategory) .ThenInclude(obj => obj.Product) .ThenInclude(product => product.ProductDescription) .ThenInclude(desc => desc.Translations) .Include(organization => organization.Categories) .ThenInclude(category => category.ProductsInCategory) .ThenInclude(obj => obj.Product) .ThenInclude(product => product.ProductName) .ThenInclude(name => name.Translations) .Include(organization => organization.Categories) .ThenInclude(category => category.ProductsInCategory) .ThenInclude(obj => obj.Product) .ThenInclude(product => product.Prices) .Where(organization => organization.IsDeleted == false) .ToListAsync(); return(o.Select(OrganizationMapper.FromDomain).ToList()); }
public async Task <List <DALLoanGivenDTO> > AllUserGivenLoans(int appUserId) { var givenLoans = await RepoDbSet .Include(loan => loan.ReceiptParticipant) .ThenInclude(participant => participant.Receipt) .Include(loan => loan.LoanTaker) .Include(loan => loan.LoanRows) .ThenInclude(loanRow => loanRow.ReceiptRow) .ThenInclude(receiptRow => receiptRow.Receipt) .Include(loan => loan.LoanRows) .ThenInclude(loanRow => loanRow.ReceiptRow) .ThenInclude(receiptRow => receiptRow.Product) .ThenInclude(product => product.Prices) .Include(loan => loan.LoanRows) .ThenInclude(loanRow => loanRow.ReceiptRow) .ThenInclude(receiptRow => receiptRow.ReceiptRowChanges) .ThenInclude(receiptRowChange => receiptRowChange.Change) .ThenInclude(change => change.Prices) .Where(loan => loan.LoanGiverId == appUserId).ToListAsync(); return(givenLoans .Select(LoanGivenMapper.FromDomain) .Where(dto => dto != null && dto.OwedAmount > decimal.Zero) .ToList()); }
public async Task <DALChangeDTO> FindDTOAsync(int changeId) { var change = await RepoDbSet .Include(c => c.ChangeName) .ThenInclude(name => name.Translations) .Include(c => c.ChangeInCategories) .ThenInclude(obj => obj.Category) .Include(c => c.Prices) .Where(c => c.IsDeleted == false && c.Id == changeId) .SingleOrDefaultAsync(); if (change == null) { return(null); } var currentPrice = PriceFinder.ForChange(change, change.Prices, DateTime.Now); if (currentPrice == null) { return(null); } return(ChangeMapper.FromDomain(change)); }
/// <summary> /// Returns Amount, Product(...), Changes(...), Participants(...), Discount, ReceiptId, RowId, Cost, /// </summary> /// <param name="receiptId"></param> /// <param name="time"></param> /// <returns></returns> public async Task <List <DALReceiptRowDTO> > AllReceiptsRows(int receiptId, DateTime time) { var rows = await RepoDbSet .Include(row => row.Product) .ThenInclude(product => product.ProductName) .ThenInclude(name => name.Translations) .Include(row => row.Product) .ThenInclude(product => product.ProductDescription) .ThenInclude(desc => desc.Translations) .Include(row => row.Product) .ThenInclude(product => product.Prices) .Include(row => row.ReceiptRowChanges) .ThenInclude(receiptRowChange => receiptRowChange.Change) .ThenInclude(change => change.ChangeName) .ThenInclude(name => name.Translations) .Include(row => row.ReceiptRowChanges) .ThenInclude(receiptRowChange => receiptRowChange.Change) .ThenInclude(change => change.Prices) .Include(row => row.RowParticipantLoanRows) .ThenInclude(row => row.Loan) .ThenInclude(loan => loan.LoanTaker) .Where(row => row.ReceiptId == receiptId) .ToListAsync(); return(rows .Select(row => ReceiptRowMapper.FromDomain(row, time)) .Where(dto => dto != null) .ToList()); }
/// <summary> /// Returns Amount, Product(...), Changes(...), Participants(...), Discount, ReceiptId, RowId, Cost, /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <DALReceiptRowDTO> FindRowAndRelatedDataAsync(int id) { var receiptRow = await RepoDbSet .Include(row => row.Receipt) .Include(row => row.Product) .ThenInclude(product => product.ProductName) .ThenInclude(name => name.Translations) .Include(row => row.Product) .ThenInclude(product => product.ProductDescription) .ThenInclude(desc => desc.Translations) .Include(row => row.Product) .ThenInclude(product => product.Prices) .Include(row => row.ReceiptRowChanges) .ThenInclude(receiptRowChange => receiptRowChange.Change) .ThenInclude(change => change.ChangeName) .ThenInclude(name => name.Translations) .Include(row => row.ReceiptRowChanges) .ThenInclude(receiptRowChange => receiptRowChange.Change) .ThenInclude(change => change.Prices) .Include(row => row.RowParticipantLoanRows) .ThenInclude(row => row.Loan) .ThenInclude(loan => loan.LoanTaker) .FirstOrDefaultAsync(row => row.Id == id); if (receiptRow == null) { return(null); } return(ReceiptRowMapper.FromDomain(receiptRow, DateTime.Now)); }
public override async Task <IEnumerable <ReceiptRow> > AllAsync() { return(await RepoDbSet .Include(row => row.Product) .Include(row => row.Receipt) .ToListAsync()); }
public override async Task <IEnumerable <LoanRow> > AllAsync() { return(await RepoDbSet .Include(loanRow => loanRow.ReceiptRow) .Include(loanRow => loanRow.Loan) .ToListAsync()); }
public override async Task <IEnumerable <ReceiptRowChange> > AllAsync() { return(await RepoDbSet .Include(rowChange => rowChange.ReceiptRow) .Include(rowChange => rowChange.Change) .ToListAsync()); }
public override async Task <IEnumerable <Price> > AllAsync() { return(await RepoDbSet .Include(price => price.Product) .Include(price => price.Change) .ToListAsync()); }
public override async Task <IEnumerable <ReceiptParticipant> > AllAsync() { return(await RepoDbSet .Include(participant => participant.AppUser) .Include(participant => participant.Receipt) .ToListAsync()); }
public async Task <DTO.WorkoutRoutine> FindFullRoutineWithIdAsync(Guid routineId) { var workoutRoutine = await RepoDbSet.Include(routine => routine.TrainingCycles) .ThenInclude(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays) .ThenInclude(day => day.TrainingDayType) .Include(routine => routine.TrainingCycles) .ThenInclude(cycle => cycle.TrainingWeeks) .ThenInclude(trainingWeek => trainingWeek.TrainingDays) .ThenInclude(exercise => exercise.ExercisesInTrainingDay) .ThenInclude(exercise => exercise.ExerciseType) .Include(routine => routine.TrainingCycles) .ThenInclude(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays) .ThenInclude(day => day.ExercisesInTrainingDay) .ThenInclude(exercise => exercise.Exercise) .Include(routine => routine.TrainingCycles) .ThenInclude(cycle => cycle.TrainingWeeks) .ThenInclude(week => week.TrainingDays) .ThenInclude(day => day.ExercisesInTrainingDay) .ThenInclude(exercise => exercise.ExerciseSets) .ThenInclude(set => set.SetType) .Include(routine => routine.WorkoutRoutineInfos) .FirstOrDefaultAsync(routine => routine.Id == routineId); var mappedRoutine = Mapper.MapDomainToDAL(workoutRoutine); return(mappedRoutine); }
public override async Task <DTO.Muscle> FindAsync(Guid id) { return(Mapper.MapDomainToDAL( await RepoDbSet .Include(m => m.MuscleGroup) .SingleOrDefaultAsync(m => m.Id == id) )); }
public override async Task <IEnumerable <Loan> > AllAsync() { return(await RepoDbSet .Include(loan => loan.LoanGiver) .Include(loan => loan.LoanTaker) .Include(loan => loan.ReceiptParticipant) .ToListAsync()); }
public override async Task <IEnumerable <ProductInCategory> > AllAsync() { return(await RepoDbSet .Include(obj => obj.Category) .ThenInclude(category => category.Organization) .Include(obj => obj.Product) .ToListAsync()); }
public async Task <IEnumerable <DAL.App.DTO.Room> > AllAsync(Guid propertyId) { var query = RepoDbSet.Include(room => room.RoomFacilities) .ThenInclude(rf => rf.Facility) .Where(room => room.PropertyId == propertyId); return((await query.ToListAsync()).Select(r => Mapper.Map(r))); }
public override async Task <IEnumerable <Contact> > GetAllAsync(Guid userId, bool noTracking = true) { return(await RepoDbSet .Include(c => c.ContactType) .Include(c => c.GasStation) .Include(c => c.Retailer) .ToListAsync()); }
public override async Task <ItemInCart> FirstOrDefaultAsync(Guid id, object?userId = null, bool noTracking = true) { var domainEntity = await RepoDbSet.Include(i => i.Item).AsNoTracking() .FirstOrDefaultAsync(e => e.Id.Equals(id)); var result = Mapper.Map(domainEntity); return(result); }
public override async Task <IEnumerable <DTO.Muscle> > AllAsync() { return(( await RepoDbSet .Include(m => m.MuscleGroup) .ToListAsync()) .Select(domainEntity => Mapper.MapDomainToDAL(domainEntity) )); }
public async Task <bool> IsPartOfBaseRoutineAsync(Guid trainingDayId) { return(await RepoDbSet .Include(d => d.TrainingWeek) .ThenInclude(w => w !.TrainingCycle) .ThenInclude(c => c !.WorkoutRoutine) .AnyAsync(d => d.Id == trainingDayId && d.TrainingWeek !.TrainingCycle !.WorkoutRoutine !.AppUserId == null )); }
public override async Task <IEnumerable <ItemInCart> > AllAsync(object?userId = null, bool noTracking = true) { var query = RepoDbSet.Include(i => i.Item); var domainEntities = await query.AsNoTracking().ToListAsync(); var result = domainEntities.Select(e => Mapper.Map(e)); return(result); }
public async Task <bool> IsPartOfBaseRoutineAsync(Guid id) { return(await RepoDbSet .Include(w => w.TrainingCycle) .ThenInclude(c => c !.WorkoutRoutine) .AnyAsync(w => w.Id == id && w.TrainingCycle !.WorkoutRoutine !.AppUserId == null )); }
public override Task <Contact> FirstOrDefaultAsync(Guid id, Guid userId, bool noTracking = true) { var res = RepoDbSet .Include(c => c.ContactType) .Include(c => c.GasStation) .Include(c => c.Retailer) .FirstOrDefaultAsync(x => x.Id == id); return(res); }
public async Task <DTO.TrainingCycle> FindWithBaseRoutineIdAsync(Guid id) { var cycle = await RepoDbSet .Include(c => c.WorkoutRoutine) .FirstOrDefaultAsync(c => c.WorkoutRoutineId == id && c.WorkoutRoutine !.AppUserId == null); var mappedCycle = Mapper.MapDomainToDAL(cycle); return(mappedCycle); }
public override async Task <ItemInWarehouse> FirstOrDefaultAsync(Guid id, object?userId = null, bool noTracking = true) { var query = RepoDbSet.Include(w => w.Item) .Include(w => w.Warehouse) .AsQueryable(); var domainEntity = await query.AsNoTracking().FirstOrDefaultAsync(e => e.Id.Equals(id)); var result = Mapper.Map(domainEntity); return(result); }
public async Task <DTO.WorkoutRoutine> FindBaseRoutineAsync(Guid id) { return(Mapper.MapDomainToDAL( await RepoDbSet .Include(routine => routine.WorkoutRoutineInfos) .Where( w => w.AppUserId == null && w.Id == id ).SingleOrDefaultAsync() )); }
public async Task <IEnumerable <DTO.TrainingCycle> > AllWithRoutineIdForUserWithIdAsync(Guid id, Guid?userId) { var trainingCycles = RepoDbSet .Include(c => c.WorkoutRoutine) .Where(c => c.WorkoutRoutineId.Equals(id)); var authorizedCycles = trainingCycles .Where(c => c.WorkoutRoutine !.AppUserId.Equals(userId)); var cyclesList = await authorizedCycles.ToListAsync(); return(cyclesList.Select(Mapper.MapDomainToDAL)); }
public override async Task <Category> FirstOrDefaultAsync(Guid id, object?userId = null, bool noTracking = true) { var query = RepoDbSet .Include(c => c.ParentCategory) .Include(i => i.CategoryItems); var domainEntity = await query.AsNoTracking().FirstOrDefaultAsync(e => e.Id.Equals(id)); var result = Mapper.Map(domainEntity); return(result); }
public async Task <IEnumerable <DTO.WorkoutRoutine> > AllInactiveBaseRoutinesAsync() { return(( await RepoDbSet .Include(routine => routine.WorkoutRoutineInfos) .Where( w => w.AppUserId == null && w.ClosedAt <= DateTime.Now ).ToListAsync() ).Select(Mapper.MapDomainToDAL)); }