コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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());
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
 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
         });
     }
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
 public OrderRepository(OSContext context)
 {
     this.context = context;
 }
コード例 #7
0
 public UserDomainRepository(ILogger <UserDomainRepository> logger, OSContext osContext)
 {
     _Logger    = logger;
     _OSContext = osContext;
 }
コード例 #8
0
 public AbstractRepository(IConfiguration configuration)
 {
     Context = new OSContext(configuration);
 }
コード例 #9
0
 public RefreshTokenRepository(ILogger <RefreshTokenRepository> logger, OSContext osContext)
 {
     _Logger    = logger;
     _OSContext = osContext;
 }
コード例 #10
0
ファイル: SightRepository.cs プロジェクト: capriok/OS.Server
 public SightRepository(ILogger <SightRepository> logger, OSContext osContext)
 {
     _Logger    = logger;
     _OSContext = osContext;
 }
コード例 #11
0
 public CustomerRepository(OSContext context)
 {
     this.context = context;
 }
コード例 #12
0
 public CategoryBLL()
 {
     _context = new OSContext();
 }
コード例 #13
0
 public UserBLL()
 {
     _context = new OSContext();
 }
コード例 #14
0
 public EmployeeRepository(OSContext context)
 {
     this.context = context;
 }