Beispiel #1
0
        public CategoryDTO GetProductCategory(ProductDTO prod)
        {
            var cat = _uow.Categories.GetAll()
                      .Where(c => c.Products
                             .Any(p => p.ProductId == prod.ProductId));

            return(BLLMapper.Map <CategoryDTO>(cat));
        }
        public ProductDTO GetWithMinPrice()
        {
            var products = _uow.Products.GetAll();

            int min = products.Min(p => p.Price);

            return(products.Where(p => p.Price == min)
                   .Select(product => BLLMapper.Map <ProductDTO>(product))
                   .FirstOrDefault());
        }
        public IEnumerable <SupplierDTO> GetProductSuppliers(ProductDTO prod)
        {
            var sups = _uow.Suppliers.GetAll()
                       .Select(s => BLLMapper.Map <SupplierDTO>(s));
            List <SupplierDTO> result = new List <SupplierDTO>();

            foreach (var sup in sups)
            {
                if (sup.Products.Any(
                        p => p.ProductId == prod.ProductId))
                {
                    result.Add(sup);
                }
            }
            return(result);
        }
Beispiel #4
0
        public IEnumerable <CategoryDTO> GetSupplierCategories(SupplierDTO sup)
        {
            IEnumerable <ProductDTO> prod = BLLMapper.Map <SupplierDTO>
                                                (_uow.Suppliers.GetById(sup.SupplierId)).Products;
            var cats = _uow.Categories.GetAll()
                       .Select(c => BLLMapper.Map <CategoryDTO>(c));

            List <CategoryDTO> res = new List <CategoryDTO>();

            foreach (var p in prod)
            {
                res.Concat(cats.Where(c => c.Products.Any(
                                          product => product.ProductId == p.ProductId)));
            }

            return(res);
        }
        public IEnumerable <SupplierDTO> GetCategorySuppliers(CategoryDTO cat)
        {
            IEnumerable <ProductDTO> prod = (BLLMapper.Map <CategoryDTO>
                                                 (_uow.Categories.GetById(cat.CategoryId))).Products;
            var sups = _uow.Suppliers.GetAll()
                       .Select(s => BLLMapper.Map <SupplierDTO>(s));

            List <SupplierDTO> res = new List <SupplierDTO>();

            foreach (var p in prod)
            {
                res.Concat(sups.Where(s => s.Products.Any(
                                          product => product.ProductId == p.ProductId)));
            }


            return(res);
        }
 public void Update(SupplierDTO sup)
 {
     _uow.Suppliers.Update(BLLMapper.Map <Supplier>(sup));
     _uow.Save();
 }
        public IEnumerable <ProductDTO> GetBySupplier(SupplierDTO sup)
        {
            var supplier = _uow.Suppliers.GetById(sup.SupplierId);

            return(BLLMapper.Map <SupplierDTO>(supplier).Products);
        }
 public ProductDTO GetById(int id)
 {
     return(BLLMapper.Map <ProductDTO>
                (_uow.Products.GetById(id)));
 }
        public IEnumerable <ProductDTO> GetByCategory(CategoryDTO cat)
        {
            var category = _uow.Categories.GetById(cat.CategoryId);

            return(BLLMapper.Map <CategoryDTO>(category).Products);
        }
 public IEnumerable <ProductDTO> GetAll()
 {
     return(_uow.Products.GetAll()
            .Select(product => BLLMapper.Map <ProductDTO>(product)));
 }
 public void Update(ProductDTO prod)
 {
     _uow.Products.Update(BLLMapper.Map <Product>(prod));
     _uow.Save();
 }
        public async Task <List <Quiz> > GetFriendQuizzes(Guid id, Guid?userId = null, bool noTracking = true)
        {
            var friends    = new List <AppUser>();
            var userMapper = new BLLMapper <DAL.App.DTO.Identity.AppUser, AppUser>();
            var quizzes    = new List <Quiz>();
            var user       = await UOW.AppUsers.GetUserWithFriendsCollections(id);

            if (user.ReceivedRequests != null)
            {
                friends.AddRange(from request in user.ReceivedRequests where request.Accepted select userMapper.Map(request.AppUser));
            }
            if (user.SentRequests != null)
            {
                friends.AddRange(from request in user.SentRequests where request.Accepted select userMapper.Map(request.Recipient));
            }

            foreach (var q in friends.Select(friend =>
                                             UOW.AppUsers.GetUserWithQuizCollections(friend.Id).Result.Quizzes !.Where(a => !a.Finished)))
            {
                quizzes.AddRange(q.Select(quiz => Mapper.Map(quiz)));
            }


            return(quizzes);
        }
Beispiel #13
0
 public CategoryDTO GetById(int id)
 {
     return(BLLMapper.Map <CategoryDTO>
                (_uow.Categories.GetById(id)));
 }
Beispiel #14
0
        public async Task <IEnumerable <ItemType> > GetAllByRestaurantAsync(Guid restaurantId, object?userId = null, bool noTracking = true)
        {
            var dalEntities = await ServiceRepository.GetAllByRestaurantAsync(restaurantId, userId, noTracking);

            return(dalEntities.Select(e => BLLMapper.Map(e)).OrderBy(e => e.IsSpecial).ThenBy(e => e.Name));
        }
 public SupplierDTO GetById(int id)
 {
     return(BLLMapper.Map <SupplierDTO>
                (_uow.Suppliers.GetById(id)));
 }
 public IEnumerable <SupplierDTO> GetAll()
 {
     return(_uow.Suppliers.GetAll()
            .Select(s => BLLMapper.Map <SupplierDTO>(s)));
 }
Beispiel #17
0
 public void Update(CategoryDTO cat)
 {
     _uow.Categories.Update(BLLMapper.Map <Category>(cat));
     _uow.Save();
 }
 public async Task <IEnumerable <NutritionInfo> > GetAllByItemAsync(Guid itemId, object?userId = null, bool noTracking = true)
 {
     return((await ServiceRepository.GetAllAsync(userId, noTracking)).Where(n => n.ItemId.Equals(itemId))
            .Select(e => BLLMapper.Map(e)));
 }
Beispiel #19
0
 public IEnumerable <CategoryDTO> GetAll()
 {
     return(_uow.Categories.GetAll()
            .Select(c => BLLMapper.Map <CategoryDTO>(c)));;
 }