public List <Category> GetFeaturedCategories(int?pageNo = 1, int?recordSize = 0, bool includeProducts = false) { var context = DataContextHelper.GetNewContext(); var categories = context.Categories .Where(x => !x.IsDeleted && x.isFeatured) .OrderBy(x => x.ID) .AsQueryable(); if (recordSize.HasValue && recordSize.Value > 0) { pageNo = pageNo ?? 1; var skip = (pageNo.Value - 1) * recordSize.Value; categories = categories.Skip(skip) .Take(recordSize.Value); } if (includeProducts) { categories = categories.Include("Products.ProductRecords"); } return(categories.ToList()); }
public List <Language> SearchLanguages(string searchTerm, out int count, bool enabledLanguagesOnly = false, int?pageNo = 1, int?recordSize = 0) { var context = DataContextHelper.GetNewContext(); var languages = context.Languages .Where(x => !x.IsDeleted) .AsQueryable(); if (!string.IsNullOrEmpty(searchTerm)) { languages = languages.Where(x => x.Name.Contains(searchTerm)); } if (enabledLanguagesOnly) { languages = languages.Where(x => x.IsEnabled); } count = languages.Count(); languages = languages.OrderBy(x => x.ID); if (recordSize.HasValue && recordSize.Value > 0) { pageNo = pageNo ?? 1; var skip = (pageNo.Value - 1) * recordSize.Value; languages = languages.Skip(skip) .Take(recordSize.Value); } return(languages.ToList()); }
public List <Order> SearchOrders(string userID, int?orderID, int?orderStatus, int?pageNo, int recordSize, out int count) { var context = DataContextHelper.GetNewContext(); var orders = context.Orders.AsQueryable(); if (!string.IsNullOrEmpty(userID)) { orders = orders.Where(x => x.CustomerID.Equals(userID)); } if (orderID.HasValue && orderID.Value > 0) { orders = orders.Where(x => x.ID == orderID.Value); } if (orderStatus.HasValue && orderStatus.Value > 0) { orders = orders.Where(x => x.OrderHistory.OrderByDescending(y => y.ModifiedOn).FirstOrDefault().OrderStatus == orderStatus); } count = orders.Count(); pageNo = pageNo ?? 1; var skipCount = (pageNo.Value - 1) * recordSize; return(orders.OrderByDescending(x => x.PlacedOn).Skip(skipCount).Take(recordSize).ToList()); }
public List <Language> GetLanguages(bool enabledLanguagesOnly = false, int?pageNo = 1, int?recordSize = 0) { var context = DataContextHelper.GetNewContext(); var languages = context.Languages .Where(x => !x.IsDeleted) .AsQueryable(); if (enabledLanguagesOnly) { languages = languages.Where(x => x.IsEnabled); } languages = languages.OrderBy(x => x.Name); if (recordSize.HasValue && recordSize.Value > 0) { pageNo = pageNo ?? 1; var skip = (pageNo.Value - 1) * recordSize.Value; languages = languages.Skip(skip) .Take(recordSize.Value); } return(languages.ToList()); }
public List <Category> SearchCategories(int?parentCategoryID, string searchTerm, int?pageNo, int recordSize, out int count) { var context = DataContextHelper.GetNewContext(); var categories = context.Categories.Where(x => !x.IsDeleted).AsQueryable(); if (!string.IsNullOrEmpty(searchTerm)) { categories = context.CategoryRecords .Where(x => !x.Category.IsDeleted && x.Name.ToLower().Contains(searchTerm.ToLower())) .Select(x => x.Category) .AsQueryable(); } if (parentCategoryID.HasValue && parentCategoryID.Value > 0) { categories = categories.Where(x => x.ParentCategoryID == parentCategoryID.Value); } count = categories.Count(); pageNo = pageNo ?? 1; var skipCount = (pageNo.Value - 1) * recordSize; return(categories.OrderBy(x => x.ID).Skip(skipCount).Take(recordSize).ToList()); }
public bool UpdatePromo(Promo promo) { var context = DataContextHelper.GetNewContext(); context.Entry(promo).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges() > 0); }
public bool SaveProductRecord(ProductRecord productRecord) { var context = DataContextHelper.GetNewContext(); context.ProductRecords.Add(productRecord); return(context.SaveChanges() > 0); }
public bool SaveProduct(Product product) { var context = DataContextHelper.GetNewContext(); context.Products.Add(product); return(context.SaveChanges() > 0); }
public bool SaveCategoryRecord(CategoryRecord categoryRecord) { var context = DataContextHelper.GetNewContext(); context.CategoryRecords.Add(categoryRecord); return(context.SaveChanges() > 0); }
public Category GetCategoryByName(string sanitizedCategoryName) { var context = DataContextHelper.GetNewContext(); var category = context.Categories.FirstOrDefault(x => x.SanitizedName.Equals(sanitizedCategoryName)); return(category != null && !category.IsDeleted ? category : null); }
public Category GetCategoryByID(int ID) { var context = DataContextHelper.GetNewContext(); var category = context.Categories.Find(ID); return(category != null && !category.IsDeleted ? category : null); }
public bool LanguageHasResources(Language language) { var context = DataContextHelper.GetNewContext(); var languageResources = context.LanguageResources.Where(x => x.LanguageID == language.ID); return(languageResources.Count() > 0); }
public Comment GetCommentByID(int ID) { var context = DataContextHelper.GetNewContext(); var comment = context.Comments.FirstOrDefault(x => x.ID == ID); return(comment != null && !comment.IsDeleted ? comment : null); }
public bool AddComment(Comment comment) { var context = DataContextHelper.GetNewContext(); context.Comments.Add(comment); return(context.SaveChanges() > 0); }
public bool AddOrderHistory(OrderHistory orderHistory) { var context = DataContextHelper.GetNewContext(); context.OrderHistories.Add(orderHistory); return(context.SaveChanges() > 0); }
public Product GetProductByID(int ID) { var context = DataContextHelper.GetNewContext(); var product = context.Products.Include("Category.CategoryRecords").Include("ProductPictures.Picture").FirstOrDefault(x => x.ID == ID); return(product != null && !product.IsDeleted && !product.Category.IsDeleted ? product : null); }
public ProductRecord GetProductRecordByID(int ID) { var context = DataContextHelper.GetNewContext(); var productRecord = context.ProductRecords.Find(ID); return(productRecord != null && !productRecord.IsDeleted ? productRecord : null); }
public CategoryRecord GetCategoryRecordByID(int ID) { var context = DataContextHelper.GetNewContext(); var categoryRecord = context.CategoryRecords.Find(ID); return(categoryRecord != null && !categoryRecord.IsDeleted ? categoryRecord : null); }
public decimal GetMaxProductPrice() { var context = DataContextHelper.GetNewContext(); var products = context.Products.Where(x => !x.IsDeleted && !x.Category.IsDeleted); return(products.Count() > 0 ? products.Max(x => x.Price) : 0); }
public bool SaveCategory(Category category) { var context = DataContextHelper.GetNewContext(); context.Categories.Add(category); return(context.SaveChanges() > 0); }
public bool SavePromo(Promo Promo) { var context = DataContextHelper.GetNewContext(); context.Promos.Add(Promo); return(context.SaveChanges() > 0); }
public bool SaveOrder(Order order) { var context = DataContextHelper.GetNewContext(); context.Orders.Add(order); return(context.SaveChanges() > 0); }
public bool UpdateConfiguration(Configuration configuration) { var context = DataContextHelper.GetNewContext(); context.Entry(configuration).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges() > 0); }
public bool UpdateProductRecord(ProductRecord productRecord) { var context = DataContextHelper.GetNewContext(); var existingRecord = context.ProductRecords.Find(productRecord.ID); context.Entry(existingRecord).CurrentValues.SetValues(productRecord); return(context.SaveChanges() > 0); }
public bool UpdateProduct(Product product) { var context = DataContextHelper.GetNewContext(); var existingProduct = context.Products.Find(product.ID); context.Entry(existingProduct).CurrentValues.SetValues(product); return(context.SaveChanges() > 0); }
public int SavePicture(Picture picture) { var context = DataContextHelper.GetNewContext(); context.Pictures.Add(picture); context.SaveChanges(); return(picture.ID); }
public bool UpdateCategoryRecord(CategoryRecord categoryRecord) { var context = DataContextHelper.GetNewContext(); var existingRecord = context.CategoryRecords.Find(categoryRecord.ID); context.Entry(existingRecord).CurrentValues.SetValues(categoryRecord); return(context.SaveChanges() > 0); }
public bool UpdateCategory(Category category) { var context = DataContextHelper.GetNewContext(); var existingCategory = context.Categories.Find(category.ID); context.Entry(existingCategory).CurrentValues.SetValues(category); return(context.SaveChanges() > 0); }
public List <Product> SearchProducts(List <int> categoryIDs, string searchTerm, decimal?from, decimal?to, string sortby, int?pageNo, int recordSize, out int count) { var context = DataContextHelper.GetNewContext(); var products = context.Products .Where(x => !x.IsDeleted && !x.Category.IsDeleted) .AsQueryable(); if (!string.IsNullOrEmpty(searchTerm)) { products = context.ProductRecords .Where(x => !x.IsDeleted && x.Name.ToLower().Contains(searchTerm.ToLower())) .Select(x => x.Product) .AsQueryable(); } if (categoryIDs != null && categoryIDs.Count > 0) { products = products.Where(x => categoryIDs.Contains(x.CategoryID)); } if (from.HasValue && from.Value > 0.0M) { products = products.Where(x => x.Price >= from.Value); } if (to.HasValue && to.Value > 0.0M) { products = products.Where(x => x.Price <= to.Value); } if (!string.IsNullOrEmpty(sortby)) { if (string.Equals(sortby, "price-high", StringComparison.OrdinalIgnoreCase)) { products = products.OrderByDescending(x => x.Price); } else { products = products.OrderBy(x => x.Price); } } else //sortBy Product Date { products = products.OrderByDescending(x => x.ModifiedOn); } count = products.Count(); pageNo = pageNo ?? 1; var skipCount = (pageNo.Value - 1) * recordSize; return(products.Skip(skipCount).Take(recordSize).Include("Category.CategoryRecords").Include("ProductPictures.Picture").ToList()); }
public bool DeletePromo(int ID) { var context = DataContextHelper.GetNewContext(); var promos = context.Promos.Find(ID); promos.IsDeleted = true; context.Entry(promos).State = System.Data.Entity.EntityState.Modified; return(context.SaveChanges() > 0); }