public IQueryable <Medicine> SearchMedicine(int Category, int SubCategory, string Name) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <Medicine> query = _db.Medicines; var result = from q in query where q.DF_subname.Contains(Name) || q.DF_subname2.Contains(Name) || q.Name.Contains(Name) || q.Name2.Contains(Name) || q.DF_mID.Contains(Name) || q.ID.ToString().Contains(Name) || Name.Contains(q.ID.ToString()) orderby q.ID select q; if (Category != 0) { result = from q in result where q.MCategoryID == Category orderby q.ID select q; } if (SubCategory != 0) { result = from q in result where q.MSubCategoryID == SubCategory orderby q.ID select q; } return(result); }
public IQueryable <MCategory> GetMCategories() { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <MCategory> query = _db.MCategories; query = query.OrderBy(MCategory => MCategory.MCategoryID); return(query); }
public IQueryable <Medicine> SearchMedicineById(int ID) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <Medicine> query = _db.Medicines; var result = from q in query where q.ID == ID select q; return(result); }
protected IQueryable <Medicine> GetMedicinesInCategoryDescending(int CategoryID, int SubCategoryID) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <Medicine> query = _db.Medicines; var result = from q in query where q.MCategoryID == CategoryID && (SubCategoryID == 0 || q.MSubCategoryID == SubCategoryID) orderby q.ID descending select q; return(result); }
public IQueryable <Medicine> SearchMedicine(string Name) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <Medicine> query = _db.Medicines; var result = from q in query where (q.DF_subname.Contains(Name) || q.DF_subname2.Contains(Name) || q.Name.Contains(Name) || q.Name2.Contains(Name) || q.DF_mID.Contains(Name)) orderby q.ID select q; return(result); }
public MSubCategory GetMSubCategoryById(int ID) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <MSubCategory> query = _db.MSubCategories; var result = from q in query where q.MSubCategoryID == ID select q; if (result.Count() != 0) { return(result.First()); } return(null); }
public IQueryable <Medicine> GetMedicine(int CategoryID) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <Medicine> query = _db.Medicines; query = query.OrderBy(Medicine => Medicine.ID); List <Medicine> result = new List <Medicine>(); foreach (var Medicine in query) { if (Medicine.MCategoryID != CategoryID) { continue; } result.Add(Medicine); } return(result.AsQueryable <Medicine>()); }
public IQueryable <MSubCategory> GetMSubCategories(int lower_bound, int upper_bound) { var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <MSubCategory> query = _db.MSubCategories; query = query.OrderBy(MSubCategory => MSubCategory.MSubCategoryID); List <MSubCategory> result = new List <MSubCategory>(); foreach (var SubItem in query) { if (SubItem.MSubCategoryID < lower_bound || SubItem.MSubCategoryID > upper_bound) { continue; } result.Add(SubItem); } return(result.AsQueryable <MSubCategory>()); }
protected int GetRightBoundary(int left) { if (left % 100 == 0) { return(left + 100); } var _db = new PrescriptionManual.Models.MedicineContext(); IQueryable <MSubCategory> query = _db.MSubCategories; query = query.OrderBy(MSubCategory => MSubCategory.MSubCategoryID); query = from q in query where q.MSubCategoryID > left select q; if (query.Count() == 0 || query.First().MSubCategoryID / 100 != left / 100) { return(((int)((left + 100) / 100)) * 100); // If the next subcategory is in a different category } else { return(query.First().MSubCategoryID); } }