示例#1
0
        // PUT api/Friend/5
        public IHttpActionResult PutFriend(int id, Friend friend)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != friend.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Phone,Email,City")] Friend friend)
 {
     if (ModelState.IsValid)
     {
         db.Entry(friend).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(friend));
 }
示例#3
0
 public ActionResult Edit([Bind(Include = "indeks,id,ime,mestonaziveenje")] FriendModel friendModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(friendModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(friendModel));
 }
 public ActionResult Edit([Bind(Include = "ID,FriendID,Name,Hometown")] FriendModel friendModel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(friendModel).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(friendModel));
 }