Пример #1
0
 public List <Product> ProductView()
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.product.ToList());
     }
 }
Пример #2
0
 public List <ProductCategory> ProductCategoryView()
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.productcategory.ToList());
     }
 }
Пример #3
0
 public object ToSearchCustomer(string UserName)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.user.Where(model => model.Email == UserName).FirstOrDefault());
     }
 }
Пример #4
0
 public object ToDisplay(int UserId)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.user.Where(model => model.UserId == UserId).FirstOrDefault());
     }
 }
Пример #5
0
 public object ToDisplayProductCategory(int CategoryId)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.productcategory.Where(model => model.CategoryId == CategoryId).FirstOrDefault());
     }
 }
Пример #6
0
 public List <User> CustomerView()
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.user.ToList());
     }
 }
Пример #7
0
 public object ToDisplayProduct(int ProductId)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.product.Where(model => model.ProductId == ProductId).FirstOrDefault());
     }
 }
Пример #8
0
 public List <Orders> OrdersView()
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         return(userDataBase.orders.ToList());
     }
 }
Пример #9
0
 public bool ToRegisterProduct(Product product)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         userDataBase.product.Add(product);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #10
0
 public bool ToRegisterOrder(Orders order)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         userDataBase.orders.Add(order);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #11
0
 public bool ToUpdate(User user)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         userDataBase.Entry(user).State = EntityState.Modified;
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #12
0
 public bool ToRegister(User user)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         userDataBase.user.Add(user);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #13
0
 public bool ToUpdateProductCategory(ProductCategory productCategory)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         userDataBase.Entry(productCategory).State = EntityState.Modified;
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #14
0
 public bool ToRegisterProductCategory(ProductCategory productCategory)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         userDataBase.productcategory.Add(productCategory);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #15
0
 public bool ToDeleteProductCategory(int CategoryId, ProductCategory productCategory)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         productCategory = userDataBase.productcategory.Where(model => model.CategoryId == CategoryId).FirstOrDefault();
         userDataBase.productcategory.Remove(productCategory);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #16
0
 public bool ToDelete(int UserId, User user)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         user = userDataBase.user.Where(model => model.UserId == UserId).FirstOrDefault();
         userDataBase.user.Remove(user);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #17
0
 public bool ToDeleteProduct(int ProductId, Product product)
 {
     using (UserDataBase userDataBase = new UserDataBase())
     {
         product = userDataBase.product.Where(model => model.ProductId == ProductId).FirstOrDefault();
         userDataBase.product.Remove(product);
         userDataBase.SaveChanges();
         return(true);
     }
 }
Пример #18
0
 public User CheckLogin(User user)
 {
     using (UserDataBase userContext = new UserDataBase())
     {
         var userdata = (from a in userContext.user where a.Email == user.Email || a.Email == user.Email select a).FirstOrDefault();
         var hashcode = userdata.HashCode;
         var encodingPasswordString = Helper.EncodePassword(user.Password, hashcode);
         var obj = userContext.user.Where(a => a.Email == user.Email && a.Password.Equals(encodingPasswordString)).FirstOrDefault();
         return(obj);
     }
 }