public async Task <IActionResult> PutData([FromRoute] int id, [FromBody] Message data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != data.Id) { return(BadRequest()); } _context.Entry(data).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DataExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMessage(int id, Message message) { if (id != message.MessageId) { return(BadRequest()); } _context.Entry(message).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MessageExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Edit([Bind(Include = "MessageId,Message,EmptyMessage,MessgeDate")] Messages messages) { if (ModelState.IsValid) { db.Entry(messages).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(messages)); }