// TODO :: finish // GET: MemberArea/Messages/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MessageThread messageThread = _uow.GetRepository <IMessageThreadRepository>() .GetUserThread((int)id, User.Identity.GetUserId <int>()); if (messageThread == null) { return(HttpNotFound()); } DetailsModel detailsModel = new DetailsModel() { Author = messageThread.Author.Email, // TODO :: fix Title = messageThread.Title, NewMessageModel = new CreateModel(), DetailsModels = _uow.GetRepository <IMessageRepository>() .GetAllByThreadIdAndUserId(messageThread.MessageThreadId, User.Identity.GetUserId <int>()) .Select(DetailsModelFactory.CreateFromMessage) .ToList(), }; return(View(detailsModel)); }
public ActionResult Details(int?id, DetailsModel detailsModel) { int activeUserId = Convert.ToInt32(User.Identity.GetUserId()); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } MessageThread messageThread = _uow.GetRepository <IMessageThreadRepository>() .GetUserThread((int)id, activeUserId); if (messageThread == null) { return(HttpNotFound()); } if (ModelState.IsValid) { Message message = detailsModel.NewMessageModel.GetMessage(); message.MessageThreadId = messageThread.MessageThreadId; // TODO :: FIX message.AuthorId = activeUserId; _uow.GetRepository <IMessageRepository>().Add(message); _uow.Commit(); return(RedirectToAction("Details", new { id = messageThread.MessageThreadId })); } detailsModel.Author = messageThread.Author.Email; // TODO :: fix detailsModel.Title = messageThread.Title; detailsModel.DetailsModels = _uow.GetRepository <IMessageRepository>() .GetAllByThreadIdAndUserId(messageThread.MessageThreadId, User.Identity.GetUserId <int>()) .Select(DetailsModelFactory.CreateFromMessage) .ToList(); return(View(detailsModel)); }