public List <Product> GetProducts(string search, int pageNo, int pageSize)
 {
     using (var context = new EMSDBContext())
     {
         if (!string.IsNullOrEmpty(search))
         {
             return(context.Products.Where(product => product.Name != null &&
                                           product.Name.ToLower().Contains(search.ToLower()))
                    .OrderBy(x => x.ID)
                    .Skip((pageNo - 1) * pageSize)
                    .Take(pageSize)
                    .Include(x => x.Category)
                    .ToList());
         }
         else
         {
             return(context.Products
                    .OrderBy(x => x.ID)
                    .Skip((pageNo - 1) * pageSize)
                    .Take(pageSize)
                    .Include(x => x.Category)
                    .ToList());
         }
     }
 }
Example #2
0
 //GetAll Projects
 public List <Project> GetAll()
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         return(db.Project.ToList());
     }
 }
 public List <Product> GetProducts(List <int> IDs)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Products.Where(product => IDs.Contains(product.ID)).ToList());
     }
 }
 public List <Product> GetProductsByCategory(int categoryID, int pageSize)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Products.Where(x => x.Category.ID == categoryID).OrderByDescending(x => x.ID).Take(pageSize).Include(x => x.Category).ToList());
     }
 }
 public Category GetCategory(int ID)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Categories.Find(ID));
     }
 }
Example #6
0
 public Config GetConfig(string Key)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Configurations.Find(Key));
     }
 }
Example #7
0
 public Order GetOrderByID(int ID)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Orders.Where(x => x.ID == ID).Include(x => x.OrderItems).Include("OrderItems.Product").FirstOrDefault());
     }
 }
Example #8
0
 //Get Employee By Id
 public Employee GetById(string eid)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         return(db.Employee.Find(eid));
     }
 }
Example #9
0
 //Get All Employees
 public List <Employee> GetAll()
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         return(db.Employee.ToList());
     }
 }
 public List <Product> GetProducts(int pageNO, int pageSize)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Products.OrderByDescending(x => x.ID).Skip((pageNO - 1) * pageSize).Take(pageSize).Include(x => x.Category).ToList());
     }
 }
 public List <Product> GetLatestProducts(int numberOfProducts)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Products.OrderByDescending(x => x.ID).Take(numberOfProducts).Include(x => x.Category).ToList());
     }
 }
Example #12
0
 //Get Project By Id
 public Project GetById(int id)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         return(db.Project.Find(id));
     }
 }
 public Product GetProduct(int ID)
 {
     using (var context = new EMSDBContext())
     {
         return(context.Products.Where(x => x.ID == ID).Include(x => x.Category).FirstOrDefault());
     }
 }
 public int GetMaximumPrice()
 {
     using (var context = new EMSDBContext())
     {
         return((int)(context.Products.Max(x => x.Price)));
     }
 }
 public List <Category> GetFeaturedCategories()
 {
     using (var context = new EMSDBContext())
     {
         return(context.Categories.Where(x => x.IsFeatured && x.ImageURL != null).ToList());
     }
 }
        public List <Category> GetCategories(string search, int pageNO, int pageSize)
        {
            //int pageSize = 6;

            using (var context = new EMSDBContext())
            {
                if (!string.IsNullOrEmpty(search))
                {
                    return(context.Categories.Where(category => category.Name != null &&
                                                    category.Name.ToLower().Contains(search.ToLower()))
                           .OrderBy(x => x.ID)
                           .Skip((pageNO - 1) * pageSize)
                           .Take(pageSize)
                           .Include(x => x.Products)
                           .ToList());
                }
                else
                {
                    return(context.Categories
                           .OrderBy(x => x.ID)
                           .Skip((pageNO - 1) * pageSize)
                           .Take(pageSize)
                           .Include(x => x.Products)
                           .ToList());
                }
            }
        }
 public void UpdateProduct(Product product)
 {
     using (var context = new EMSDBContext())
     {
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #18
0
 public void Update(Project item)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         db.Project.Update(item);
         db.SaveChanges();
     }
 }
 public void UpdateCategory(Category category)
 {
     using (var context = new EMSDBContext())
     {
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
     }
 }
Example #20
0
 public int SaveOrder(Order order)
 {
     using (var context = new EMSDBContext())
     {
         context.Orders.Add(order);
         return(context.SaveChanges());
     }
 }
 public List <Category> GetAllCategories()
 {
     using (var context = new EMSDBContext())
     {
         return(context.Categories
                .ToList());
     }
 }
 //Add Employee
 public void Add(Employee item)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         db.Employee.Add(item);
         db.SaveChanges();
     }
 }
 public void SaveCategory(Category category)
 {
     using (var context = new EMSDBContext())
     {
         context.Categories.Add(category);
         context.SaveChanges();
     }
 }
Example #24
0
 public void Update(Employee employee)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         db.Employee.Update(employee);
         db.SaveChanges();
     }
 }
Example #25
0
 //Delete Project
 public void Delete(int id)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         Project p = db.Project.Find(id);
         db.Project.Remove(p);
         db.SaveChanges();
     }
 }
 public void SaveProduct(Product product)
 {
     using (var context = new EMSDBContext())
     {
         context.Entry(product.Category).State = System.Data.Entity.EntityState.Unchanged;
         context.Products.Add(product);
         context.SaveChanges();
     }
 }
 public void DeleteProduct(int ID)
 {
     using (var context = new EMSDBContext())
     {
         var product = context.Products.Find(ID);
         context.Products.Remove(product);
         context.SaveChanges();
     }
 }
Example #28
0
        public int ShopPageSize()
        {
            using (var context = new EMSDBContext())
            {
                var pageSizeConfig = context.Configurations.Find("ShopPageSize");

                return(pageSizeConfig != null?int.Parse(pageSizeConfig.Value) : 8);
            }
        }
 //Delete Record
 public void Delete(string eid)
 {
     using (EMSDBContext db = new EMSDBContext())
     {
         Employee e = db.Employee.Find(eid);
         db.Employee.Remove(e);
         db.SaveChanges();
     }
 }
        public List <Product> GetProducts(int pageNO)
        {
            int pageSize = 15; //int.Parse(ConfigurationsManager.Instance.GetConfig("ListingPageSize").Value);

            using (var context = new EMSDBContext())
            {
                return(context.Products.OrderBy(x => x.ID).Skip((pageNO - 1) * pageSize).Take(pageSize).Include(x => x.Category).ToList());
                //return context.Products.Include(x => x.Category).ToList();
            }
        }