public List <UserModel> ReadUsers() { using (var context = new WebShopContext()) { List <UserModel> users = context.UserModel.ToList(); return(users); } }
public void InsertUser(UserModel userModel) { using (var context = new WebShopContext()) { context.UserModel.Add(userModel); context.SaveChanges(); } }
public UserModel GetUserByName(string name) { using (var context = new WebShopContext()) { UserModel user = context.UserModel.Where(u => u.Name == name).FirstOrDefault(); return(user); } }
public void InsertContact(ContactModel contactModel) { using (var context = new WebShopContext()) { context.ContactModel.Add(contactModel); context.SaveChanges(); } }
public List <CategoriesModel> ReadCategories() { using (var context = new WebShopContext()) { List <CategoriesModel> categories = context.CategoriesModel.ToList(); return(categories); } }
public List <RecipesModel> ReadRecipes() { using (var context = new WebShopContext()) { List <RecipesModel> recipes = context.RecipesModel.ToList(); return(recipes); } }
public List <BrandsModel> ReadBrands() { using (var context = new WebShopContext()) { List <BrandsModel> brands = context.BrandsModel.ToList(); return(brands); } }
public void DeleteProduct(int id) { using (var context = new WebShopContext()) { context.Remove(context.ProductModel.Select(p => p.ProductId == id)); context.SaveChanges(); } }
public BrandsModel getBrandByName(string name) { using (var context = new WebShopContext()) { BrandsModel brand = context.BrandsModel.Where(p => p.Name == name).SingleOrDefault(); return(brand); } }
public UserModel True(LoginModel loginModel) { using (var context = new WebShopContext()) { UserModel user = context.UserModel.Where(u => u.Email == loginModel.Email && u.Password == loginModel.Password).FirstOrDefault(); return(user); } }
public List <ProductModel> PriceRange(int min, int max) { using (var context = new WebShopContext()) { List <ProductModel> listProducts = context.ProductModel.Where(p => (p.SalePrice <= Convert.ToDecimal(max) && p.SalePrice >= Convert.ToDecimal(min)) && (p.Price <= Convert.ToDecimal(max) && p.Price >= Convert.ToDecimal(min))).ToList(); return(listProducts); } }
public void DeleteRecipe(int id) { using (var context = new WebShopContext()) { context.Remove(context.RecipesModel.Select(p => p.RecipeId == id)); context.SaveChanges(); } }
public CategoriesModel getCategoryByName(string name) { using (var context = new WebShopContext()) { CategoriesModel categorie = context.CategoriesModel.Where(p => p.Name == name).SingleOrDefault(); return(categorie); } }
public List <ProductModel> ReadProducts() { using (var context = new WebShopContext()) { List <ProductModel> products = context.ProductModel.ToList(); return(products); } }
public List <OrdersModel> ReadOrders() { using (var context = new WebShopContext()) { List <OrdersModel> orders = context.OrdersModel.ToList(); return(orders); } }
public void DeleteCategory(int id) { using (var context = new WebShopContext()) { context.Remove(context.CategoriesModel.Select(p => p.CategoryId == id)); context.SaveChanges(); } }
public void InsertOrder(OrdersModel ordersModel) { using (var context = new WebShopContext()) { context.OrdersModel.Add(ordersModel); context.SaveChanges(); } }
public void DeleteOrder(int id) { using (var context = new WebShopContext()) { context.Remove(context.OrdersModel.Select(p => p.OrderId == id)); context.SaveChanges(); } }
public List <RestaurantsModel> ReadRestaurants() { using (var context = new WebShopContext()) { List <RestaurantsModel> restaurants = context.RestaurantsModel.ToList(); return(restaurants); } }
public List <ProductModel> GetProductsByCategory(int id) { using (var context = new WebShopContext()) { List <ProductModel> products = context.ProductModel.Where(p => p.CategoryId == id).ToList(); return(products); } }
public void InsertCategory(CategoriesModel categoriesModel) { using (var context = new WebShopContext()) { context.CategoriesModel.Add(categoriesModel); context.SaveChanges(); } }
public void InsertProduct(ProductModel productModel) { using (var context = new WebShopContext()) { context.ProductModel.Add(productModel); context.SaveChanges(); } }
public void InsertRecipe(RecipesModel recipesModel) { using (var context = new WebShopContext()) { context.RecipesModel.Add(recipesModel); context.SaveChanges(); } }
public List <ProductModel> Search(string searchBy) { using (var context = new WebShopContext()) { List <ProductModel> products = context.ProductModel.Where(p => p.Name.Contains(searchBy)).ToList(); return(products); } }
public void DeleteBrand(int id) { using (var context = new WebShopContext()) { context.Remove(context.BrandsModel.Select(p => p.BrandId == id)); context.SaveChanges(); } }
public void InsertBrand(BrandsModel brandsModel) { using (var context = new WebShopContext()) { context.BrandsModel.Add(brandsModel); context.SaveChanges(); } }
public ProductModel ProductDetail(int productId) { using (var context = new WebShopContext()) { ProductModel productModel = context.ProductModel.Where(p => p.ProductId == productId).FirstOrDefault(); productModel.categoryModel = context.CategoriesModel.Where(p => p.CategoryId == productModel.CategoryId).FirstOrDefault(); productModel.brandModel = context.BrandsModel.Where(p => p.BrandId == productModel.BrandId).FirstOrDefault(); return(productModel); } }
public UserModel DeleteMaxId(List <UserModel> list) { using (var context = new WebShopContext()) { var id = list.Max(u => u.UserId); UserModel deleteUser = context.UserModel.Where(u => u.UserId == id).FirstOrDefault(); context.UserModel.Remove(deleteUser); context.SaveChanges(); return(deleteUser); } }
public List <OrderLineModel> ReadOrderLines() { using (var context = new WebShopContext()) { List <OrderLineModel> orderLines = context.OrderLineModel.ToList(); foreach (var item in orderLines) { item.Product = context.ProductModel.Where(p => p.ProductId == item.ProductId).FirstOrDefault(); } return(orderLines); } }
public int OrderToBase(int userId, decimal totalPrice) { var dateTime = DateTime.Now; int orderId; using (var context = new WebShopContext()) { OrdersModel order = new OrdersModel(userId, dateTime, totalPrice); context.OrdersModel.Add(order); context.SaveChanges(); OrdersModel orderForUser = context.OrdersModel.Where(p => p.UserId == userId && p.Date == dateTime).FirstOrDefault(); orderId = orderForUser.OrderId; } return(orderId); }