public ActionResult GetMessagesWith(Guid id, int page = 1, int itemPerPage = 0) { var messageRep = IoC.Instance.Resolve<IMessageRepository>(); var rep = IoC.Instance.Resolve<IUserRepository>(); var currentUser = CurrentUser.Info.UserModel; var recipient = rep.GetByHash(id); var defaultPageSize = Int32.Parse(SettingsProvider.Instance.Settings[Settings.ChatPageSize].Value); var model = new PrivateChatRoom { Messages = messageRep.GetMessagesBetweenUsers(currentUser.Id, recipient.Id, new PagingInfo { CurrentPage = page, ItemsPerPage = itemPerPage == 0 ? defaultPageSize : itemPerPage, }) }; return new JsonResult { Data = model.MessagesJson, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; }
public ActionResult StartChatWith(Guid id) { var messageRep = IoC.Instance.Resolve<IMessageRepository>(); var rep = IoC.Instance.Resolve<IUserRepository>(); var currentUser = CurrentUser.Info.UserModel; var recipient = rep.GetByHash(id); var pageSize = Int32.Parse(SettingsProvider.Instance.Settings[Settings.ChatPageSize].Value); var model = new PrivateChatRoom { Author = currentUser, Recipient = recipient, MessagesAmount = messageRep.GetCount(currentUser.Id, recipient.Id), Messages = messageRep.GetMessagesBetweenUsers(currentUser.Id, recipient.Id, new PagingInfo { CurrentPage = 0, ItemsPerPage = pageSize }) }; return View("ChatView", model); }