public void CreateMessage(User_Message userMessage) { context.Messages.Add(userMessage.Message); userMessage.Message_Id = userMessage.Message.Message_Id; context.User_Message.Add(userMessage); SaveChanges(); }
public IHttpActionResult SendMessage(User_Message userMessage) { if (userMessage == null) { return BadRequest(); } _messageRepository.CreateMessage(userMessage); return Ok(); }
public bool SendMessage(User_Message userMessage) { try { var content = new StringContent(JsonConvert.SerializeObject(userMessage)); var response = client.PostAsync("Message/SendMessage", content).Result; switch (response.StatusCode) { case HttpStatusCode.OK: return true; case HttpStatusCode.NotFound: throw new MissingMethodException(); default: return false; } } catch (Exception ex) { throw; } }
public RedirectToRouteResult Reply(ReplyViewModel model) { var userMessage = new User_Message() { Sender = "test-username", Reciever = model.To, Message = new Message() { Sent_Date = DateTime.Now, Subject = model.Subject, Message1 = model.Message } }; _messageManager.SendMessage(userMessage); return RedirectToAction("Inbox"); }