示例#1
0
        public ActionResult DeleteConfirmed(string id)
        {
            ChatMessageRealm chatMessageRealm = db.ChatMessages.Find(id);

            db.ChatMessages.Remove(chatMessageRealm);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
 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));
 }
示例#3
0
        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));
        }
示例#4
0
        // 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));
        }
示例#5
0
        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));
        }