Beispiel #1
0
 public static bool ChangeUserPassword(User user)
 {
     using (StoreManagementEntities store = new StoreManagementEntities())
     {
         store.Entry(user).State = EntityState.Modified;
         if (store.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
 public static bool DecreaseFromStock(int productID, int numberOfProducts)
 {
     using (StoreManagementEntities store = new StoreManagementEntities())
     {
         var product = store.Product.Where(s => s.ID == productID).First();
         product.Stock -= numberOfProducts;
         if (store.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
 public static bool CRUDProduct(Product product, EntityState state)
 {
     using (StoreManagementEntities store = new StoreManagementEntities())
     {
         if (state == EntityState.Deleted)
         {
             product.RegistrationStatus = (byte)RegistrationStatus.Passive;
         }
         else
         {
             store.Entry(product).State = state;
             product.RegistrationStatus = (byte)RegistrationStatus.Active;
         }
         if (store.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
 public static bool CRUDCustomer(Customer customer, EntityState state)
 {
     using (StoreManagementEntities store = new StoreManagementEntities())
     {
         if (state == EntityState.Deleted)
         {
             customer.RegistrationStatus = (byte)RegistrationStatus.Passive;
             store.Entry(customer).State = EntityState.Modified;
         }
         else
         {
             store.Entry(customer).State = state;
             customer.RegistrationStatus = (byte)RegistrationStatus.Active;
         }
         if (store.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
 public void Save()
 {
     DbContext.SaveChanges();
 }
 public JsonResult AddProduct(Product product)
 {
     StoreManagementEntitiesdb.Entry(product).State = EntityState.Added;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }
 public int Save()
 {
     return(DbContext.SaveChanges());
 }
Beispiel #8
0
 public JsonResult AddStore(Store store)
 {
     StoreManagementEntitiesdb.Entry(store).State = EntityState.Added;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }
 public JsonResult AddCustomer(Customer customer)
 {
     //StoreManagementEntitiesdb.Customers.Add(customer);
     StoreManagementEntitiesdb.Entry(customer).State = EntityState.Added;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }
Beispiel #10
0
 public JsonResult AddSale(ProductSold ps)
 {
     StoreManagementEntitiesdb.ProductSolds.Add(ps);
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }