Esempio n. 1
0
        public async Task <IActionResult> PutPassword(int id, Password password)
        {
            if (id != password.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "ID,FirstName,LastName")] Author author)
 {
     if (ModelState.IsValid)
     {
         db.Entry(author).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(author));
 }
 public ActionResult Edit([Bind(Include = "ID,BookTitle,BookContent,Rate")] Book book)
 {
     if (ModelState.IsValid)
     {
         db.Entry(book).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(book));
 }
Esempio n. 4
0
        // PUT api/myobjects/
        // The PUT command will be send along with the object
        // Compare this to the scaffolded version to see the difference.
        public HttpResponseMessage PutMyObject(MyObject myObject)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, myObjet));
        }