예제 #1
0
 public ActionResult Edit(Product product, int ProductModelId, int ProductCategoryID, int ProductSubCategoryID, HttpPostedFileBase file)
 {
     product.ProductModelId       = ProductModelId;
     product.ProductSubCategoryID = ProductSubCategoryID;
     product.rowguid      = Guid.NewGuid();
     product.ModifiedDate = DateTime.Now;
     if (ModelState.IsValid)
     {
         if (file != null)
         {
             Photo photo = new Photo();
             photo.rowguid      = Guid.NewGuid();
             photo.ModifiedDate = DateTime.Now;
             photo.Name         = file.FileName;
             photo.Image        = new byte[file.ContentLength];
             file.InputStream.Read(photo.Image, 0, file.ContentLength);
             context.Entry(photo).State = EntityState.Modified;
             context.Photo.Add(photo);
             context.SaveChanges();
         }
         context.Entry(product).State = EntityState.Modified;
         context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
예제 #2
0
 public ActionResult Edit(ProductModel model)
 {
     model.ModifiedDate         = DateTime.Now;
     context.Entry(model).State = EntityState.Modified;
     context.SaveChanges();
     return(RedirectToAction("List"));
 }
예제 #3
0
 public ActionResult Edit(ProductSubCategory category)
 {
     category.ModifiedDate         = DateTime.Now;
     context.Entry(category).State = EntityState.Modified;
     context.SaveChanges();
     return(RedirectToAction("List"));
 }
예제 #4
0
        public async Task <IActionResult> PutCustomer(int id, Customer customer)
        {
            if (id != customer.CustomerId)
            {
                return(BadRequest());
            }

            _context.Entry(customer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            if (id != product.ProductId)
            {
                return(BadRequest());
            }

            _context.Entry(product).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }