public Category GetCategoryDetail(int categoryId) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { return(context.Categorys.ToList().Where(id => id.CategoryId == categoryId).SingleOrDefault()); } }
public CustomerDetails GetCustomerDetails(int Id) { using (OnlineShoppingDB_Context Context = new OnlineShoppingDB_Context()) { return(Context.Customers.FirstOrDefault(p => p.CustomerId == Id)); } }
public IEnumerable <Category> GetCategory() { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { return(context.Categorys.ToList()); } }
public Product GetProductDetails(int idProduct) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { return(context.Products.ToList().Where(id => id.ProductId == idProduct).SingleOrDefault()); } }
//static OnlineShoppingDB_Context context = new OnlineShoppingDB_Context(); public IEnumerable <Product> GetProduct() { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { return(context.Products.Include("Category").ToList()); } }
public static void CustomerUpdate(CustomerDetails Customer) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { context.Entry(Customer).State = EntityState.Modified; context.SaveChanges(); } }
public void Add(CustomerDetails customer) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { context.Entry(customer).State = EntityState.Added; context.SaveChanges(); } }
//public static List<CustomerDetails> customers = new List<CustomerDetails>(); public IEnumerable <CustomerDetails> GetCustomer() { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { return(context.Customers.ToList()); } // return new List<CustomerDetails>(); }
public void Add(Product product) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { context.Entry(product).State = EntityState.Added; context.SaveChanges(); } }
public static void ProductUpdate(Product product) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { //product = context.ProductDB.FirstOrDefault(prod => prod.productId == product.productId); context.Entry(product).State = EntityState.Modified; context.SaveChanges(); } }
public void CategoryDelete(int categoryId) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { Category category = new Category(); category = context.Categorys.Find(categoryId); context.Entry(category).State = EntityState.Deleted; context.SaveChanges(); } }
public void ProductDelete(Product product) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { product = context.Products.Find(product.ProductId); context.Entry(product).State = EntityState.Deleted; context.SaveChanges(); } //context.ProductDB.Attach(product); }
public void Add(Category category) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { SqlParameter sqlParameter = new SqlParameter("@CategoryName", category.CategoryName); int count = context.Database.ExecuteSqlCommand("Category_Insert @CategoryName", sqlParameter); } //using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) //{ // context.Entry(category).State = EntityState.Added; // context.SaveChanges(); //} }
public static CustomerDetails LoginValidate(CustomerDetails customer) { using (OnlineShoppingDB_Context context = new OnlineShoppingDB_Context()) { customer = context.Customers.Where(id => (customer.CustomerEMail == id.CustomerEMail || customer.CustomerMobile == id.CustomerMobile && customer.CustomerPassword == id.CustomerPassword)).SingleOrDefault(); try { return(customer); } catch (NullReferenceException) { return(null); } } }