Exemplo n.º 1
0
 public IEnumerable<User> GetUsers()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.UserRepository.GetAll(user => user.IsAdmin == false);
     }
 }
 public IEnumerable<Category> GetCategories()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.CategoryRepository.GetAll();
     }
 }
Exemplo n.º 3
0
 public User FindUser(int id)
 {
     using (var uow = new UnitOfWork())
     {
         return uow.UserRepository.Find(id);
     }
 }
 public Product FindProduct(int productId)
 {
     using (var uow = new UnitOfWork())
     {
         return uow.ProductRepository.Find(productId);
     }
 }
 public Category FindCategory(int id)
 {
     using (var uow = new UnitOfWork())
     {
         return uow.CategoryRepository.Find(id);
     }
 }
 public IEnumerable<Country> GetCountries()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.CountryRepository.GetAll(orderBy: o => o.OrderBy(c => c.Name));
     }
 }
 public static bool CredentialsAreValid(string userId, string password)
 {
     using (var uow = new UnitOfWork())
     {
         IEnumerable<User> users = uow.UserRepository.GetAll(u => u.Email == userId && u.Password == password);
         return users != null && users.Count() == 1;
     }
 }
Exemplo n.º 8
0
 public bool EditUser(User user)
 {
     using (var uow = new UnitOfWork())
     {
         uow.UserRepository.Update(user);
         return uow.Save() > 0;
     }
 }
Exemplo n.º 9
0
 public bool DeleteUser(int id)
 {
     using (var uow = new UnitOfWork())
     {
         uow.UserRepository.Delete(id);
         return uow.Save() > 0;
     }
 }
Exemplo n.º 10
0
 public bool CreateUser(User user)
 {
     using (var uow = new UnitOfWork())
     {
         uow.UserRepository.Insert(user);
         return uow.Save() == 1;
     }
 }
 public bool InsertReview(ProductReview review)
 {
     using (var uow = new UnitOfWork())
     {
         uow.ReviewRepository.Insert(review);
         return uow.Save() == 1;
     }
 }
Exemplo n.º 12
0
 public bool CreateNewOrder(Cart cart)
 {
     using (var uow = new UnitOfWork())
     {
         uow.CartRepository.Insert(cart);
         return uow.Save() > 0;
     }
 }
 public bool EditCategory(Category category)
 {
     using (var uow = new UnitOfWork())
     {
         uow.CategoryRepository.Update(category);
         return uow.Save() > 0;
     }
 }
 public bool DeleteCategory(int id)
 {
     using (var uow = new UnitOfWork())
     {
         uow.CategoryRepository.Delete(id);
         return uow.Save() > 0;
     }
 }
 public bool CreateCategory(Category category)
 {
     using (var uow = new UnitOfWork())
     {
         uow.CategoryRepository.Insert(category);
         return uow.Save() == 1;
     }
 }
 public IEnumerable<ProductReview> GetReviewsByProduct(int productId)
 {
     using (var uow = new UnitOfWork())
     {
         return uow.ReviewRepository.GetAll(
             filter: review => review.ProductId == productId && review.Approved,
             orderBy: review => review.OrderBy(x => x.Rating),
             includeProperties: "User");
     }
 }
 public IEnumerable<ProductReview> GetUnapprovedReviews()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.ReviewRepository.GetAll(
             filter: review => review.Approved == false,
             orderBy: review => review.OrderBy(x => x.PostingDate),
             includeProperties: "User,Product");
     }
 }
Exemplo n.º 18
0
 public Cart GetActiveOrder(int id)
 {
     using (var uow = new UnitOfWork())
     {
         return uow.CartRepository.GetAll(
             filter: order => order.Id == id,
             orderBy: null,
             includeProperties: "User,CartItems,ShippingDetail,CreditCard").Single();
     }
 }
Exemplo n.º 19
0
 public IEnumerable<Cart> GetActiveOrders()
 {
     using (var uow = new UnitOfWork())
     {
         return uow.CartRepository.GetAll(
             filter: order => order.Status == CartStatus.Open,
             orderBy: order => order.OrderBy(x => x.OrderDate),
             includeProperties: "User,CartItems,ShippingDetail,CreditCard");
     }
 }
Exemplo n.º 20
0
 public Product GetProductWithDetails(int productId)
 {
     using (var uow = new UnitOfWork())
     {
         return uow.ProductRepository.GetAll(
             filter: product => product.Id == productId,
             orderBy: null,
             includeProperties: "ProductDetails"
             ).SingleOrDefault();
     }
 }
Exemplo n.º 21
0
        public IEnumerable<Product> GetProducts(int? categoryId)
        {
            using (var uow = new UnitOfWork())
            {
                if (categoryId.HasValue)
                {
                    return uow.ProductRepository.GetAll(product => product.CategoryId == categoryId);
                }

                return uow.ProductRepository.GetAll(includeProperties: "Category,ProductReviews");
            }
        }