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))); }
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))); }
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)); }
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 async Task <List <DTO.UserInTraining> > FindByAppUserId(Guid appUserId) { return((await RepoDbSet.AsQueryable() .Where(t => t.AppUserId.Equals(appUserId)) .ToListAsync()) .Select(domainEntity => Mapper.Map(domainEntity)).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()); }
/// <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()); }
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)); }
/// <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 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 override async Task <IEnumerable <LoanRow> > AllAsync() { return(await RepoDbSet .Include(loanRow => loanRow.ReceiptRow) .Include(loanRow => loanRow.Loan) .ToListAsync()); }
public override async Task <IEnumerable <ReceiptParticipant> > AllAsync() { return(await RepoDbSet .Include(participant => participant.AppUser) .Include(participant => participant.Receipt) .ToListAsync()); }
public async Task <DTO.NotificationAnswer> findbyNotificationId(Guid id) { var notAnswer = await RepoDbSet.AsQueryable() .Where(na => na.NotificationId == id).FirstOrDefaultAsync(); return(NotificationAnswerMapper.Map(notAnswer)); }
public async void UpdateUserInTraining(DAL.App.DTO.UserInTraining userInTraining) { var usr = await RepoDbSet.FindAsync(userInTraining.Id); usr.AttendingTraining = userInTraining.AttendingTraining; RepoDbSet.Update(usr); }
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 override async Task <IEnumerable <DTO.BodyMeasurement> > AllAsync() { return(( await RepoDbSet .ToListAsync() ).Select(domainEntity => Mapper.MapDomainToDAL(domainEntity))); }
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 override async Task <IEnumerable <Price> > AllAsync() { return(await RepoDbSet .Include(price => price.Product) .Include(price => price.Change) .ToListAsync()); }
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());
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 override async Task <IEnumerable <ReceiptRowChange> > AllAsync() { return(await RepoDbSet .Include(rowChange => rowChange.ReceiptRow) .Include(rowChange => rowChange.Change) .ToListAsync()); }
public DAL.App.DTO.Notification AddNewNotification(DAL.App.DTO.Notification notification) { var domainNotification = NotificationMapper.MapToDomain(notification); var addedNotification = RepoDbSet.Add(domainNotification).Entity; return(NotificationMapper.Map(addedNotification)); }
public async Task RemoveByProductId(int productId) { var objects = await RepoDbSet .Where(obj => obj.ProductId == productId) .ToListAsync(); RepoDbSet.RemoveRange(objects); }
public override async Task <IEnumerable <ProductInCategory> > AllAsync() { return(await RepoDbSet .Include(obj => obj.Category) .ThenInclude(category => category.Organization) .Include(obj => obj.Product) .ToListAsync()); }
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 <List <DALOrganizationDTO> > AllMinDTOAsync() { return((await RepoDbSet .Where(organization => organization.IsDeleted == false) .ToListAsync()) .Select(OrganizationMapper.FromDomain2) .ToList()); }
public async Task <DAL.App.DTO.Notification> FindByTrainingAndUserId(Guid userId, Guid trainingId) { var notification = RepoDbSet.AsQueryable() .Where(n => n.AppUserId == userId && n.TrainingId == trainingId) .FirstOrDefaultAsync(); return(NotificationMapper.Map(await notification)); }
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 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()); }