Exemplo n.º 1
0
 public bool Exists(int id)
 {
     return(RepositoryDbSet.Any(e => e.PersonId == id));
 }
Exemplo n.º 2
0
 public async Task <bool> BelongsToUserAsync(int id, int userId)
 {
     return(await RepositoryDbSet
            .AnyAsync(userFavouriteProvider =>
                      userFavouriteProvider.Id == id && userFavouriteProvider.AppUserId == userId));
 }
 public async Task <List <DAL.App.DTO.AdministrativeUnit> > AllForUserAsync(int userId)
 {
     return(await RepositoryDbSet
            .Select(e => AdministrativeUnitMapper.MapFromDomain(e)).ToListAsync());
 }
Exemplo n.º 4
0
 public ForumTopic FindByAuthor(string author)
 {
     return(RepositoryDbSet
            .Where(p => p.Author.ToLower().Contains(author.ToLower()))
            .FirstOrDefault());
 }
Exemplo n.º 5
0
        public override async Task <DAL.App.DTO.Client> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var client = await RepositoryDbSet.FindAsync(id);

            if (client != null)
            {
                await RepositoryDbContext.Entry(client)
                .Reference(c => c.ClientGroup)
                .LoadAsync();

                await RepositoryDbContext.Entry(client.ClientGroup)
                .Reference(c => c.Name)
                .LoadAsync();

                await RepositoryDbContext.Entry(client.ClientGroup)
                .Reference(c => c.Description)
                .LoadAsync();

                await RepositoryDbContext.Entry(client.ClientGroup.Name)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

                await RepositoryDbContext.Entry(client.ClientGroup.Description)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

                await RepositoryDbContext.Entry(client)
                .Collection(c => c.ProductsForClient)
                .LoadAsync();

                foreach (var productForClient in client.ProductsForClient)
                {
                    await RepositoryDbContext.Entry(productForClient)
                    .Reference(b => b.Product)
                    .LoadAsync();

                    await RepositoryDbContext.Entry(productForClient.Product)
                    .Reference(b => b.ProductName)
                    .LoadAsync();

                    await RepositoryDbContext.Entry(productForClient.Product.ProductName)
                    .Collection(b => b.Translations)
                    .Query()
                    .Where(t => t.Culture == culture)
                    .LoadAsync();
                }

                await RepositoryDbContext.Entry(client)
                .Collection(c => c.Bills)
                .LoadAsync();

                foreach (var bill in client.Bills)
                {
                    await RepositoryDbContext.Entry(bill)
                    .Reference(b => b.Comment)
                    .LoadAsync();

                    await RepositoryDbContext.Entry(bill.Comment)
                    .Collection(b => b.Translations)
                    .Query()
                    .Where(t => t.Culture == culture)
                    .LoadAsync();
                }
            }

            return(ClientMapper.MapFromDomain(client));
        }
Exemplo n.º 6
0
 public async Task <bool> ExistsByPrimaryKeyAsync(int keyValue)
 {
     return(await RepositoryDbSet.AnyAsync(e => e.ProjectTypeId == keyValue));
 }
 public override IEnumerable <Ingredient> All()
 {
     return(RepositoryDbSet.AsQueryable()
            .ToList());
 }
Exemplo n.º 8
0
 public override IEnumerable <Event> All()
 {
     return(RepositoryDbSet
            .Include(e => e.EventType)
            .ToList());
 }
Exemplo n.º 9
0
 public async override Task <IEnumerable <Event> > AllAsync()
 {
     return(await RepositoryDbSet
            .Include(e => e.EventType)
            .ToListAsync());
 }
 public void RemoveBySubjectEventAndTeacherIds(int subjectEventId, int teacherId)
 {
     RepositoryDbSet.Remove(RepositoryDbSet.First(entity =>
                                                  entity.TeacherId == teacherId && entity.SubjectInScheduleId == subjectEventId));
 }
Exemplo n.º 11
0
        public override async Task <DAL.App.DTO.WorkObject> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var workObject = await RepositoryDbSet.FindAsync(id);

            if (workObject != null)
            {
                await RepositoryDbContext.Entry(workObject)
                .Reference(c => c.Client)
                .LoadAsync();

//                await RepositoryDbContext.Entry(workObject.Client)
//                    .Collection(c => c.Bills)
//                    .LoadAsync();
//
//                foreach (var bill in workObject.Bills)
//                {
//                    await RepositoryDbContext.Entry(bill)
//                        .Reference(b => b.Comment)
//                        .LoadAsync();
//
//                    await RepositoryDbContext.Entry(bill.Comment)
//                        .Collection(b => b.Translations)
//                        .Query()
//                        .Where(t => t.Culture == culture)
//                        .LoadAsync();
//                }
//
//                await RepositoryDbContext.Entry(workObject)
//                    .Collection(c => c.AppUsersOnObject)
//                    .LoadAsync();
//
//                foreach (var appUserOnObject in workObject.AppUsersOnObject)
//                {
//                    await RepositoryDbContext.Entry(appUserOnObject)
//                        .Reference(b => b.AppUser)
//                        .LoadAsync();
//
//                }
//
//                await RepositoryDbContext.Entry(workObject)
//                    .Collection(c => c.ProductsServices)
//                    .LoadAsync();
//
//
//                foreach (var service in workObject.ProductsServices)
//                {
//                    await RepositoryDbContext.Entry(service)
//                        .Reference(b => b.Description)
//                        .LoadAsync();
//
//                    await RepositoryDbContext.Entry(service.Description)
//                        .Collection(b => b.Translations)
//                        .Query()
//                        .Where(t => t.Culture == culture)
//                        .LoadAsync();
//                }
            }
            return(WorkObjectMapper.MapFromDomain(workObject));
        }
Exemplo n.º 12
0
        public async Task <List <SaleWithProductCount> > AllAsyncByShopDTO(int?shopId, string search, int?pageIndex, int?pageSize)
        {
            var query = RepositoryDbSet
                        .Include(a => a.Description).ThenInclude(t => t.Translations)
                        .Include(a => a.AppUser)
                        .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ProductName)
                        .ThenInclude(t => t.Translations)
                        .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Length)
                        .ThenInclude(t => t.Translations)
                        .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.Weight)
                        .ThenInclude(t => t.Translations)
                        .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ManuFacturerItemCode)
                        .ThenInclude(t => t.Translations)
                        .Include(a => a.ProductsSold).ThenInclude(a => a.Product).ThenInclude(aa => aa.ShopCode)
                        .ThenInclude(t => t.Translations)
                        .Where(s => s.AppUser.ShopId == shopId).AsQueryable();

            query = Search(query, search);

            if (pageIndex != null && pageSize != null)
            {
                var tempPageIndex = pageIndex.GetValueOrDefault();
                var tempPageSize  = pageSize.GetValueOrDefault();
                query = query.Skip((tempPageIndex - 1) * tempPageSize).Take(tempPageSize);
            }

            var res = await query
                      .Select(s => new
            {
                Id                      = s.Id,
                Description             = s.Description,
                AppUserId               = s.AppUserId,
                AppUserName             = s.AppUser.FirstName,
                AppUserLastName         = s.AppUser.LastName,
                SaleInitialCreationTime = s.SaleInitialCreationTime,
                ProductsSoldCount       = s.ProductsSold.Count,
                DescriptionTranslations = s.Description.Translations,
                ProductsInSaleDTOs      = s.ProductsSold.Select(p => new
                {
                    Id                          = p.Id,
                    ProductId                   = p.ProductId,
                    ProductName                 = p.Product.ProductName,
                    SaleId                      = p.SaleId,
                    SaleDescription             = p.Sale.Description,
                    SaleDescriptionTranslations = p.Sale.Description.Translations,
                    ProductNameTranslations     = p.Product.ProductName.Translations
                }).ToList(),
                AllTotalSaleAmount   = s.ProductsSold.Sum(e => e.Quantity *e.Product.SellPrice),
                TodayTotalSaleAmount = s.ProductsSold.Where(e => DateTime.Today < e.ProductSoldTime && e.ProductSoldTime < DateTime.Today.AddDays(1).AddTicks(-1))
                                       .Sum(e => e.Quantity *e.Product.SellPrice)
            })
                      .ToListAsync();

            var result = res.Select(s => new SaleWithProductCount()
            {
                Id                      = s.Id,
                Description             = s.Description.Translate(),
                AppUserId               = s.AppUserId,
                AppUserName             = s.AppUserName,
                AppUserLastName         = s.AppUserLastName,
                SaleInitialCreationTime = s.SaleInitialCreationTime,
                ProductsSoldCount       = s.ProductsSoldCount,
                ProductsInSaleDTOs      = s.ProductsInSaleDTOs.Select(p => new ProductSoldProductSaleIdName()
                {
                    Id              = p.Id,
                    ProductId       = p.ProductId,
                    ProductName     = p.ProductName.Translate(),
                    SaleId          = p.SaleId,
                    SaleDescription = p.SaleDescription.Translate()
                }).ToList(),
                AllTotalSaleAmount   = s.AllTotalSaleAmount,
                TodayTotalSaleAmount = s.TodayTotalSaleAmount
            }).ToList();

            return(result);
        }
Exemplo n.º 13
0
        public async Task <List <DAL.App.DTO.Dog> > AllForUserAsync(int userId)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var resultList = await RepositoryDbSet
                             .Include(a => a.Breed)
                             .ThenInclude(a => a.BreedName)
                             .ThenInclude(a => a.Translations)
                             .Include(a => a.AppUser)
                             .Include(a => a.Sex)
                             .ThenInclude(a => a.Translations)
                             .Where(p => p.AppUserId == userId)
                             .Select(c => DogMapper.MapFromDomain(c))
                             .ToListAsync();



//           var resultList = await RepositoryDbSet
//                .Include(a=> a.Breed)
//                .ThenInclude( a=> a.BreedName)
//                .ThenInclude( a=> a.Translations)
//                .Include(a => a.Sex)
//                .ThenInclude( a=> a.Translations)
//                .Include( a=> a.Owner)
//                .Include( a=> a.DateOfBirth)
//
//
//                .Where( a=> a.AppUserId == userId)
//                .Select(c => DogMapper.MapFromDomain(c))
//                .ToListAsync();
//
//            var res = await RepositoryDbSet
//                .Where(b => b.AppUserId == userId)
//                .Select(c => new
//                {
//                    Id = c.Id,
//                    DogName = c.DogName,
//                    Breed = c.Breed,
//                    Owner = c.Owner,
//                    DateOfBirth = c.DateOfBirth,
//                    DateOfDeath = c.DateOfDeath,
//                    Sex = c.Sex,
//                    Translations = c.Sex.Translations,
//
//                })
//                .ToListAsync();
//
//            var resultList = res.Select(c => new  DTO.Dog()
//            {
//                Id = c.Id,
//                DogName = c.DogName,
//               // Breed = c.Breed,
//                DateOfBirth = c.DateOfBirth,
//                DateOfDeath = c.DateOfDeath,
//                Owner = c.Owner,
//                Sex = c.Sex.Translate(),
//
//
//            }).ToList();
            return(resultList);
        }
Exemplo n.º 14
0
 /// <summary>
 /// Get all acitve orders
 /// </summary>
 /// <param name="userId">Useraccont id</param>
 /// <returns> list of orders</returns>
 public List <TruckInOrder> GetAllTruckInOrders(int userId)
 {
     return(RepositoryDbSet
            .Where(o => o.Order.UnloadingDateTime > DateTime.Now && o.Order.UserAccontId == userId || o.Truck.UserAccontId == userId).ToList());
 }
Exemplo n.º 15
0
 public async Task <Project> GetSingle(int id)
 {
     return(await RepositoryDbSet
            .Where(i => i.ProjectId == id)
            .SingleOrDefaultAsync());
 }
Exemplo n.º 16
0
 public override Event Find(params object[] id)
 {
     return(RepositoryDbSet
            .Include(e => e.EventType)
            .SingleOrDefault(e => e.EventId == (int)id[0]));
 }
Exemplo n.º 17
0
 public async Task <Project> GetSingleWithProjectType(int id)
 {
     return(await RepositoryDbSet
            .Include(p => p.ProjectType)
            .SingleOrDefaultAsync(m => m.ProjectId == id));
 }
Exemplo n.º 18
0
 public override Task <Event> FindAsync(params object[] id)
 {
     return(RepositoryDbSet
            .Include(e => e.EventType)
            .SingleOrDefaultAsync(e => e.EventId == (int)id[0]));
 }
Exemplo n.º 19
0
 public bool Exists(int id)
 {
     return(RepositoryDbSet.Any(e => e.IngredientId == id));
 }
 public async Task <Disease> FindByNameAsync(string name)
 {
     return(await RepositoryDbSet.FirstOrDefaultAsync(d => d.DiseaseName == name));
 }
Exemplo n.º 21
0
 public ForumTopic FindTopicByTitle(string title)
 {
     return(RepositoryDbSet
            .Where(p => p.Title.ToLower().Contains(title.ToLower()))
            .FirstOrDefault());
 }
 public async Task <Disease> GetByIdWithSymptomsAsync(int id)
 {
     return(await RepositoryDbSet.Include(d => d.Symptoms).ThenInclude(s => s.Symptom).FirstOrDefaultAsync(x => x.DiseaseId == id));
 }
Exemplo n.º 23
0
        public Task <TIdentityRole> FindByNameAsync(string normalizedName, CancellationToken cancellationToken = default(CancellationToken))
        {
            var firstOrDefaultAsync = RepositoryDbSet.FirstOrDefaultAsync(predicate: r => r.NormalizedName == normalizedName, cancellationToken: cancellationToken);

            return(firstOrDefaultAsync);
        }
Exemplo n.º 24
0
 public async Task <MultiLangString> FindSingleAsync(int id)
 {
     return(await RepositoryDbSet
            .Include(t => t.Translations)
            .FirstOrDefaultAsync(m => m.MultiLangStringId == id));
 }
Exemplo n.º 25
0
 public async Task <IList <Claim> > GetClaimsAsync(TKey roleId, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await RepositoryDbSet.Where(predicate : rc => rc.IdentityRoleId.Equals(roleId)).Select(selector: c => new Claim(c.ClaimType, c.ClaimValue)).ToListAsync(cancellationToken: cancellationToken));
 }
 public override IEnumerable <Invoice> All()
 {
     return(RepositoryDbSet
            .Include(i => i.InvoiceRows)
            .ToList());
 }
Exemplo n.º 27
0
 public async Task <Screen> GetFirstAndActiveScreenAsync()
 {
     return(ScreenMapper.MapFromDomain(await RepositoryDbSet.AsNoTracking().FirstOrDefaultAsync(s => s.IsActive)));
 }
 public override Invoice Find(params object[] id)
 {
     return(RepositoryDbSet
            .Include(i => i.InvoiceRows)
            .SingleOrDefault(i => i.InvoiceId == (int)id[0]));
 }
 public async Task <bool> BelongsToUserAsync(int id, int userId)
 {
     return(await RepositoryDbSet
            .AnyAsync(c => c.Id == id && c.AppUserId == userId));
 }
Exemplo n.º 30
0
 public async Task <int> CountProductsInReturn(int returnId)
 {
     return(await RepositoryDbSet
            .Where(r => r.ReturnId == returnId).CountAsync());
 }