コード例 #1
0
        // PUT api/<controller>/5
        public object Put(string userid, Login u)
        {
            try
            {
                if (userid == u.Userid)
                {
                    lg.Entry(u).State = System.Data.Entity.EntityState.Modified;
                    lg.SaveChanges();
                    return(new Response
                    {
                        Status = "Updated",
                    });
                }
                else
                {
                    return(new Response
                    {
                        Status = "opps",
                    });
                }
            }
            catch (Exception e)
            {
                Console.Write("error");
            }

            return(new Response
            {
                Status = "Error",
            });
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "no,product_id,product_name,quantity,unit_price,stored_date")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
 public void Update(User update)
 {
     try
     {
         _DbContext.Entry(update).State = System.Data.Entity.EntityState.Modified;
         _DbContext.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #5
0
 public static bool CRUDSale(Sale sale, EntityState state)
 {
     using (StoreManagementEntities store = new StoreManagementEntities())
     {
         store.Entry(sale).State = state;
         if (store.SaveChanges() > 0)
         {
             return(true);
         }
         return(false);
     }
 }
コード例 #6
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);
     }
 }
コード例 #7
0
 public void Update(User update)
 {
     if (update != null)
     {
         try
         {
             _Context.Entry(update).State = EntityState.Modified;
             _Context.SaveChanges();
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
コード例 #8
0
        public async Task <ActionResult> Edit([Bind(Include = "ProductID,Name,Price,CreateDate,ModifyDate,InStock")] Products products)
        {
            if (ModelState.IsValid)
            {
                db.Entry(products).State = EntityState.Modified;

                products.CreateDate = System.DateTime.Now;
                products.ModifyDate = System.DateTime.Now;

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(products));
        }
コード例 #9
0
 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 void UpdateCustomer(Customer customer)
 {
     DbContext.Entry(customer).State = EntityState.Modified;
 }
コード例 #11
0
 public JsonResult AddProduct(Product product)
 {
     StoreManagementEntitiesdb.Entry(product).State = EntityState.Added;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }
コード例 #12
0
 public virtual void UpdateRecord(T entity)
 {
     Dbcontext.Entry(entity).State = EntityState.Modified;
 }
コード例 #13
0
 public JsonResult AddStore(Store store)
 {
     StoreManagementEntitiesdb.Entry(store).State = EntityState.Added;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }
コード例 #14
0
 public JsonResult AddCustomer(Customer customer)
 {
     //StoreManagementEntitiesdb.Customers.Add(customer);
     StoreManagementEntitiesdb.Entry(customer).State = EntityState.Added;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }
コード例 #15
0
 public JsonResult UpdateSale(ProductSold psold)
 {
     StoreManagementEntitiesdb.Entry(psold).State = EntityState.Modified;
     return(Json(StoreManagementEntitiesdb.SaveChanges()));
 }