public ActionResult DeleteConfirmed(string id) { ChatMessageRealm chatMessageRealm = db.ChatMessages.Find(id); db.ChatMessages.Remove(chatMessageRealm); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Text,AuthorName,CreatingDateTime")] ChatMessageRealm chatMessageRealm) { if (ModelState.IsValid) { db.Entry(chatMessageRealm).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chatMessageRealm)); }
public ActionResult Create([Bind(Include = "Id,Text,AuthorName,CreatingDateTime")] ChatMessageRealm chatMessageRealm) { if (ModelState.IsValid) { db.ChatMessages.Add(chatMessageRealm); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(chatMessageRealm)); }
// GET: ChatMessageRealms/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ChatMessageRealm chatMessageRealm = db.ChatMessages.Find(id); if (chatMessageRealm == null) { return(HttpNotFound()); } return(View(chatMessageRealm)); }
private void SendMessage() { if (String.IsNullOrWhiteSpace(NewMessageText)) { return; } var newMessage = new ChatMessageRealm(NewMessageText); var realm = App.GetRealm(); realm.Write(() => { realm.Add(newMessage); }); NewMessageText = String.Empty; OnPropertyChanged(nameof(NewMessageText)); }