예제 #1
0
        public IHttpActionResult Delete(int id)
        {
            var productdel = p.ProductDetails.Where(x => x.ID == id).FirstOrDefault();

            p.Entry(productdel).State = System.Data.Entity.EntityState.Deleted;
            p.SaveChanges();
            return(Ok());
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,EmailID,Password")] user_master user_master)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user_master).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user_master));
 }
예제 #3
0
 public ActionResult Edit([Bind(Include = "ItemId,CategoryId,ItemCode,ItemName,ShortDescription,LongDescription,SmallImagePath,LongImagePath,ItemPrice")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(item));
 }
예제 #4
0
        public async Task <bool> UpdateProductAsync(int id, Product product)
        {
            var eProduct = await _context.Products.FirstOrDefaultAsync(p => p.Id == id);

            if (eProduct == null)
            {
                return(false);
            }
            eProduct.ProductName = product.ProductName;
            eProduct.ProductUrl  = product.ProductUrl;
            eProduct.ProductCode = product.ProductCode;
            try
            {
                _context.Entry(eProduct).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message + ex.StackTrace + ex.InnerException;
                return(false);
            }
        }