Example #1
0
 public Product GetProduct(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         return(onlineShoppingContext.products.Where(product => product.ProductId == id).FirstOrDefault());
     }
 }
Example #2
0
 public Category GetCategory(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         return(onlineShoppingContext.Categories.Where(category => category.CategoryId == id).FirstOrDefault());
     }
 }
Example #3
0
 public Account Login(Account account)
 {
     using (OnlineShoppingContext context = new OnlineShoppingContext())
     {
         var result = context.Accounts.Where(value => value.EmailId == account.EmailId && value.Password == account.Password).FirstOrDefault();
         return(result);
     }
 }
Example #4
0
 public void AddUser(Account account)
 {
     using (OnlineShoppingContext context = new OnlineShoppingContext())
     {
         context.Accounts.Add(account);
         context.SaveChanges();
     }
 }
Example #5
0
 public List <Category> DropDownList()
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         List <Category> categories = onlineShoppingContext.Categories.ToList();
         return(categories);
     }
 }
Example #6
0
 public void Update(Product product)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.Entry(product).State = System.Data.Entity.EntityState.Modified;
         onlineShoppingContext.SaveChanges();
     }
 }
Example #7
0
 public void  AddProduct(Product product)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.products.Add(product);
         onlineShoppingContext.SaveChanges();
     }
 }
Example #8
0
 public Product Details(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         Product product = onlineShoppingContext.products.Find(id);
         return(product);
     }
 }
Example #9
0
 public List <Product> ProductDetails()
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         List <Product> data = onlineShoppingContext.products.ToList();
         return(data);
     }
 }
Example #10
0
 public void Update(Category category)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.Entry(category).State = System.Data.Entity.EntityState.Modified;
         onlineShoppingContext.SaveChanges();
     }
 }
Example #11
0
 public Category Details(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         Category category = onlineShoppingContext.Categories.Find(id);
         return(category);
     }
 }
Example #12
0
 public List <Category> CategoryDetails()
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         List <Category> data = onlineShoppingContext.Categories.ToList();
         return(data);
     }
 }
Example #13
0
 public void AddCategory(Category category)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         onlineShoppingContext.Categories.Add(category);
         onlineShoppingContext.SaveChanges();
     }
 }
Example #14
0
 public void Delete(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         Product product = onlineShoppingContext.products.Find(id);
         onlineShoppingContext.products.Remove(product);
         onlineShoppingContext.SaveChanges();
     }
 }
Example #15
0
 public void Delete(int id)
 {
     using (OnlineShoppingContext onlineShoppingContext = new OnlineShoppingContext())
     {
         Category category = onlineShoppingContext.Categories.Find(id);
         onlineShoppingContext.Categories.Remove(category);
         onlineShoppingContext.SaveChanges();
     }
 }