public IHttpActionResult PutCustomer(string id, Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != customer.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CustomerExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "Id,Venue,AvailableDate,Address")] Karaoke karaoke)
 {
     if (ModelState.IsValid)
     {
         db.Entry(karaoke).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(karaoke));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Quantity,Price")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(product));
 }
 public ActionResult Edit([Bind(Include = "Id,EmployeeName,Age,MaritialStatus,Salary,Address")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
예제 #5
0
 public ActionResult Edit([Bind(Include = "Id,Latitude,Longitude,KaraokeId")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.KaraokeId = new SelectList(db.Karaokes, "Id", "Venue", location.KaraokeId);
     return(View(location));
 }
예제 #6
0
 public ActionResult Edit([Bind(Include = "CategoryId,CategoryName,SeqNo,ParentCategoryId")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ParentCategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", category.ParentCategoryId);
     return(View(category));
 }
예제 #7
0
 public ActionResult Edit([Bind(Include = "Id,Date,Time,Until,Food_And_Drinks,Apply_For_Party,Leave_Message,Rate,CustomerId,KaraokeId")] Booking booking)
 {
     if (ModelState.IsValid)
     {
         db.Entry(booking).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.KaraokeId = new SelectList(db.Karaokes, "Id", "Venue", booking.KaraokeId);
     return(View(booking));
 }
예제 #8
0
 public ActionResult Edit([Bind(Include = "ProductId,ProductName,PrimaryCategoryId,ProductDescription,Active,ProductPrice")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PrimaryCategoryId = new SelectList(db.Categories, "CategoryId", "CategoryName", product.PrimaryCategoryId);
     return(View(product));
 }
 public virtual T Update(T entity)
 {
     dbSet.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
     return(entity);
 }