public ActionResult Messages(InboxViewModel myModel) { PersonalMessage messageToSend = new PersonalMessage(); //checks sender info and adds it too the message if (User.Identity.GetUserId() != null) { PersonalMessageHelper.ProcessSender(myModel, messageToSend, User.Identity.GetUserId()); } //checks recipient info and adds it too the message if (myModel.RecipientName != null) { PersonalMessageHelper.ProcessRecipient(myModel, messageToSend); } ModelState.Clear(); TryValidateModel(myModel); //checks if the model is valid, and finishes building the message //stores it in the DB to be grabbed //reloads the inbox if (ModelState.IsValid) { PersonalMessageHelper.ProcessBody(myModel, messageToSend); MessageDB.AddMessage(messageToSend); myModel.Messages = MessageDB.GetAllMessageForUserById(myModel.User.Id); return(RedirectToAction("Messages", "Person", new { id = myModel.User.Id })); } //checks if user is null and displays a error page if (myModel.User == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } //reloads the page return(View(myModel)); }