public IActionResult sendmsg(JObject m) { var currentUserId = int.Parse(User.Identity.Name); dynamic json = m; int contactId = (int)json.contactId; string body = json.body; var conversation = conv.getConversationbyUsersID(contactId, currentUserId); if (conversation != null) { Message me = new Message(); me.Body = body; me.Conversation_ID = conversation.ID; me.senderId = currentUserId; ctx.Messages.Add(me); ctx.SaveChanges(); return(Ok(m)); } else { return(BadRequest()); } }
public void Save() { ctx.SaveChanges(); }