public int SearchOrdersCount(string userID, string status) { using (var context = new OSContext()) { var orders = context.Orders.ToList(); if (!string.IsNullOrEmpty(userID)) { orders = orders.Where(x => x.UserID.ToLower().Contains(userID.ToLower())).ToList(); } if (!string.IsNullOrEmpty(status)) { orders = orders.Where(x => x.Status.ToLower().Contains(status.ToLower())).ToList(); } return(orders.Count); } }
public List <Order> SearchOrders(string userID, string status, int pageNo, int pageSize) { using (var context = new OSContext()) { var orders = context.Orders.ToList(); if (!string.IsNullOrEmpty(userID)) { orders = orders.Where(x => x.UserID.ToLower().Contains(userID.ToLower())).ToList(); } if (!string.IsNullOrEmpty(status)) { orders = orders.Where(x => x.Status.ToLower().Contains(status.ToLower())).ToList(); } return(orders.Skip((pageNo - 1) * pageSize).Take(pageSize).ToList()); } }
public int SearchProductsCount(string searchTerm, int?minimumPrce, int?maximunPrice, int?categoryID, int?sortBy) { using (var context = new OSContext()) { var products = context.Products.ToList(); if (categoryID.HasValue) { products = products.Where(x => x.Category.ID == categoryID.Value).ToList(); } if (!string.IsNullOrEmpty(searchTerm)) { products = products.Where(x => x.Name.ToLower().Contains(searchTerm.ToLower())).ToList(); } if (minimumPrce.HasValue) { products = products.Where(x => x.Price >= minimumPrce.Value).ToList(); } if (maximunPrice.HasValue) { products = products.Where(x => x.Price <= maximunPrice.Value).ToList(); } if (sortBy.HasValue) { switch (sortBy.Value) { case 2: products = products.OrderByDescending(x => x.ID).ToList(); break; case 3: products = products.OrderBy(x => x.Price).ToList(); break; default: products = products.OrderByDescending(x => x.Price).ToList(); break; } } return(products.Count); } }
public ItemDTO GetItem(int id) { using (var _context = new OSContext()) { Item item = _context.Items.Include("Category").FirstOrDefault(i => i.ID == id); return(new ItemDTO() { ID = item.ID, Name = item.Name, Cost = item.Cost, Category = new CategoryDTO() { Name = item.Category.Name, ID = item.Category.ID }, Descripition = item.Descripition, ImageURL = item.ImageURL, CategoryID = item.CategoryID }); } }
public List <ItemDTO> GetItems(int categoryID) { using (var _context = new OSContext()) { List <Item> itemsBeforeConvert; List <ItemDTO> items = new List <ItemDTO>(); if (categoryID == 0) { itemsBeforeConvert = _context.Items.Include("Category").ToList(); } else { itemsBeforeConvert = _context.Items .Include("Category") .Where(i => i.CategoryID == categoryID).ToList(); } foreach (Item item in itemsBeforeConvert) { items.Add( new ItemDTO() { ID = item.ID, Cost = item.Cost, Name = item.Name, ImageURL = item.ImageURL, Descripition = item.Descripition, CategoryID = item.CategoryID, Category = new CategoryDTO() { Name = item.Category.Name, ID = item.Category.ID } } ); } return(items); } }
public OrderRepository(OSContext context) { this.context = context; }
public UserDomainRepository(ILogger <UserDomainRepository> logger, OSContext osContext) { _Logger = logger; _OSContext = osContext; }
public AbstractRepository(IConfiguration configuration) { Context = new OSContext(configuration); }
public RefreshTokenRepository(ILogger <RefreshTokenRepository> logger, OSContext osContext) { _Logger = logger; _OSContext = osContext; }
public SightRepository(ILogger <SightRepository> logger, OSContext osContext) { _Logger = logger; _OSContext = osContext; }
public CustomerRepository(OSContext context) { this.context = context; }
public CategoryBLL() { _context = new OSContext(); }
public UserBLL() { _context = new OSContext(); }
public EmployeeRepository(OSContext context) { this.context = context; }