private List <List <InboxViewModel> > GetAllUndeletedMessages() { var list = new List <InboxViewModel>(); var userId = User.Identity.GetUserId(); var com = new SingleCommunication(); var allSingleMessages = com.GetAllUndeletedSingleMessages(userId); foreach (var sm in allSingleMessages) { var model = new InboxViewModel { Subjcet = sm.Message.Subject, MessageId = sm.Message.Id, Date = sm.Message.TimeCreated, Username = sm.Sender.UserName, FirstName = sm.Sender.FirstName, LastName = sm.Sender.LastName, Status = sm.Status }; list.Add(model); } var groupedList = list .OrderByDescending(x => x.Date) .GroupBy(u => u.Username) .Select(grp => grp.ToList()) .ToList(); return(groupedList); }
public IActionResult Inbox() { try { if (HttpContext.Session.GetInt32("loggedUser") == null) { return(RedirectToAction("Index", "Main")); } User loggedUser = _context.users.Where(p => p.user_id == HttpContext.Session.GetInt32("loggedUser")).FirstOrDefault(); InboxViewModel viewModel = new InboxViewModel(); viewModel.loggedUser = loggedUser; viewModel.joke = Joke(); viewModel.emails = _context.emails .Where(p => p.send_to_email == loggedUser.email) .Include(p => p.user) .ToList(); return(View(viewModel)); } catch { return(Json("Error")); } }
// GET: MailReceiverController public async Task <IActionResult> Index() { var unreadEmails = await _mailKitRepository.GetUnreadMailsAsync().ConfigureAwait(false); var emails = new List <MailViewModel>(); foreach (var email in unreadEmails) { emails.Add(new MailViewModel { ReceivedDate = email.Date, Subject = email.Subject, MessageId = email.MessageId }); //using var fileStream = System.IO.File.Create($@"C:\Users\user\source\repos\Granny.Artificial.Intelligence\Emails\{email.Date:yyyyMMddHHmmss}.eml"); //email.WriteTo(fileStream); } var inboxViewModel = new InboxViewModel { EmailAddress = _mailKitRepository.GetEmailAddress(), EmailList = emails }; return(View(inboxViewModel)); }
public async void FirstRun(bool refresh = false) { RefreshStories(refresh); PostsGenerator.RunLoadMore(refresh); InboxViewModel.ResetInstance(); if (InboxViewModel.Instance != null) { try { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (InboxViewModel.Instance.SeqId <= 0) { await InboxViewModel.Instance.RunLoadMoreAsync(refresh); } if (MainPage.Current.RealtimeClient == null) { MainPage.Current.RealtimeClient = new InstagramApiSharp.API.RealTime.RealtimeClient(InstaApi); } var client = MainPage.Current.RealtimeClient; await client.Start(InboxViewModel.Instance.SeqId, InboxViewModel.Instance.SnapshotAt); client.DirectItemChanged += InboxViewModel.Instance.RealtimeClientDirectItemChanged; client.TypingChanged += InboxViewModel.Instance.RealtimeClientClientTypingChanged; client.BroadcastChanged += RealtimeClientBroadcastChanged; }); } catch { } } //MainView.Current?.MainViewInboxUc?.InboxVM?.RunLoadMore(refresh); if (InboxViewModel.Instance?.SeqId <= 0) { ActivitiesViewModel.Instance?.RunLoadMore(refresh); } }
public async Task <IActionResult> Inbox(InboxViewModel model) { var user = await userManager.FindByNameAsync(HttpContext.User.Identity.Name); // Feed the model model.UserFriends = mumblrRepository.getUserFriends(user.Id); model.SelectedFriend = model.NewChatMessage.recipient; model.Chat = mumblrRepository.getChat(user.Id, model.NewChatMessage.recipient); // Verify that the user entered a message if (model.NewChatMessage.Message != null) { var success = mumblrRepository.addChatMessage(user.Id, model.NewChatMessage.recipient, model.NewChatMessage.Message); // Verify that the database could handle the request if (success) { return(RedirectToAction("Inbox", "home", new { model.NewChatMessage.recipient })); } // Errormessage in case the database cant handle the request else { ViewBag.ErrorMessage = "There was an error processing the message. You may contact the admin via [email protected]"; return(View("NotFound")); } } // Errormessage in case the user has not entered a valid message (Inputvalidation) else { return(View(model)); } }
public ActionResult Sent(int?pageNumber, int?pageSize) { ViewBag.ManageNavigationKey = "sent"; if (pageNumber == null || pageNumber < 1) { pageNumber = 1; } if (pageSize == null) { pageSize = 25; } if (pageSize > 100) { pageSize = 100; } if (pageSize < 1) { pageSize = 1; } var skip = (pageNumber - 1) * pageSize; var take = pageSize; var messages = _messageDao.GetSentMessagesForUser(_userContext.CurrentUser.Id, skip, take); var model = new InboxViewModel(); model.InboxType = InboxType.Sent; model.IsModerator = _moderationDao.GetSubsModeratoredByUser(_userContext.CurrentUser.Id).Count > 0; model.Messages = new PagedList <MessageWrapped>(_messageWrapper.Wrap(messages, _userContext.CurrentUser), pageNumber.Value, pageSize.Value, messages.HasMore); return(View(model)); }
public InboxPage(InboxViewModel viewModel) { viewModel.Navigation = Navigation; BindingContext = viewModel; Title = "Inbox"; Icon = "mailbox.png"; _listView = new ListView { RowHeight = 100 }; _listView.IsPullToRefreshEnabled = true; _listView.SetBinding <InboxViewModel> (ListView.ItemTemplateProperty, m => m.InboxTemplate); _listView.SetBinding <InboxViewModel> (ListView.RefreshCommandProperty, m => m.RefreshCommand); _listView.SetBinding <InboxViewModel> (ListView.SelectedItemProperty, m => m.SelectedItem); _listView.SetBinding <InboxViewModel> (ListView.IsRefreshingProperty, m => m.IsBusy); _listView.SetBinding <InboxViewModel> (ListView.ItemsSourceProperty, m => m.Inbox); // no binding available _listView.ItemTapped += (object sender, ItemTappedEventArgs e) => { viewModel.ItemSelectedCommand.Execute(null); }; Content = new StackLayout { Children = { _listView } }; //Device.StartTimer (new TimeSpan (0, 0, 30), UpdateInbox); }
public IActionResult Inbox(InboxViewModel model) { InfoHandler a = new InfoHandler(_userManager, _signInManager, _userDateTime); a.inbox(_userManager.GetUserId(User), model); a.Readmsg(_userManager.GetUserId(User), model); a.deletedMsg(_userManager.GetUserId(User), model); return(View(model)); }
public InboxView() { InitializeComponent(); var container = Application.Current.GetContainer(); vm = new InboxViewModel(Navigation, container.Resolve <IFriendService>()); BindingContext = vm; }
public async Task <IActionResult> LoadInbox() { var vm = new InboxViewModel { ClientMessages = await _clientMessageRepository.GetAllOpenClientMessagesAsync() }; return(View("Inbox", vm)); }
public void WhenExecutingTheReplyCommand_ThenNavigatesToComposeEmailViewWithId() { var email = new EmailDocument(); var emailServiceMock = new Mock <IEmailService>(); AsyncCallback callback = null; var asyncResultMock = new Mock <IAsyncResult>(); emailServiceMock .Setup(svc => svc.BeginGetEmailDocuments(It.IsAny <AsyncCallback>(), null)) .Callback <AsyncCallback, object>((ac, o) => callback = ac) .Returns(asyncResultMock.Object); emailServiceMock .Setup(svc => svc.EndGetEmailDocuments(asyncResultMock.Object)) .Returns(new[] { email }); Mock <IRegion> regionMock = new Mock <IRegion>(); regionMock .Setup(x => x.RequestNavigate(new Uri(@"ComposeEmailView?ReplyTo=" + email.Id.ToString("N"), UriKind.Relative), It.IsAny <Action <NavigationResult> >())) .Callback <Uri, Action <NavigationResult> >((s, c) => c(new NavigationResult(null, true))) .Verifiable(); Mock <IRegionManager> regionManagerMock = new Mock <IRegionManager>(); regionManagerMock.Setup(x => x.Regions.ContainsRegionWithName(RegionNames.MainContentRegion)).Returns(true); regionManagerMock.Setup(x => x.Regions[RegionNames.MainContentRegion]).Returns(regionMock.Object); var viewModel = new InboxViewModel(emailServiceMock.Object, regionManagerMock.Object); EnqueueConditional(() => callback != null); EnqueueCallback( () => { callback(asyncResultMock.Object); }); EnqueueConditional( () => { return(!viewModel.Messages.IsEmpty); }); EnqueueCallback( () => { viewModel.Messages.MoveCurrentToFirst(); viewModel.ReplyMessageCommand.Execute(null); regionMock.VerifyAll(); }); EnqueueTestComplete(); }
public InboxPage(User current_user, int folderType) { InitializeComponent(); this.current_user = current_user; if (folderType == 2) { helpTitle.Text = "View Spam"; } BindingContext = new InboxViewModel(current_user, folderType); }
public async void FirstRun(bool refresh = false) { //var u = await InstaApi.UserProcessor.GetUserAsync("rmt4006"); //var s = await InstaApi.StoryProcessor.GetUserStoryAndLivesAsync(u.Value.Pk); //var t = ""; //var live = await InstaApi.LiveProcessor.GetInfoAsync(t); //var user = await InstaApi.UserProcessor.GetUserInfoByIdAsync(15154078079); //var sss = await InstaApi.CreativeProcessor.GetAssetsAsync(); ////var inb = await Helper.InstaApi.MessagingProcessor.GetDirectInboxAsync(PaginationParameters.MaxPagesToLoad(1)); //var user = await InstaApi.UserProcessor.GetUserAsync("instagram"); //var sss = await InstaApi.MessagingProcessor.GetThreadByParticipantsAsync(0, user.Value.Pk); //var aabc = await InstaApi.AccountProcessor.GetNotificationsSettingsAsync("notifications"); ////var aabc = await InstaApi.AccountProcessor.GetNotificationsSettingsAsync("email_and_sms"); //return; /*await*/ var aaabx = await InstaApi.UserProcessor.GetFullUserInfoAsync(30808156545); var aaabxxxxxx = await InstaApi.UserProcessor.GetFullUserInfoAsync(InstaApi.GetLoggedUser().LoggedInUser.Pk); RefreshStories(refresh); //await Task.Delay(3500); //await PostsGenerator.RunLoadMoreAsync(refresh); PostsGenerator.RunLoadMore(refresh); InboxViewModel.ResetInstance(); if (InboxViewModel.Instance != null) { try { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (InboxViewModel.Instance.SeqId <= 0) { await InboxViewModel.Instance.RunLoadMoreAsync(refresh); } if (MainPage.Current.RealtimeClient == null) { MainPage.Current.RealtimeClient = new InstagramApiSharp.API.RealTime.RealtimeClient(InstaApi); } var client = MainPage.Current.RealtimeClient; await client.Start(InboxViewModel.Instance.SeqId, InboxViewModel.Instance.SnapshotAt); client.DirectItemChanged += InboxViewModel.Instance.RealtimeClientDirectItemChanged; client.TypingChanged += InboxViewModel.Instance.RealtimeClientClientTypingChanged; }); } catch { } } MainView.Current?.MainViewInboxUc?.InboxVM?.RunLoadMore(refresh); ActivitiesViewModel.Instance?.RunLoadMore(refresh); }
public void WhenCreated_ThenRequestsEmailsToService() { var emailServiceMock = new Mock <IEmailService>(); var requested = false; emailServiceMock .Setup(svc => svc.BeginGetEmailDocuments(It.IsAny <AsyncCallback>(), null)) .Callback(() => requested = true); var viewModel = new InboxViewModel(emailServiceMock.Object, new Mock <IRegionManager>().Object); Assert.IsTrue(requested); }
public void WhenExecutingTheNewCommand_ThenNavigatesToComposeEmailView() { var emailServiceMock = new Mock <IEmailService>(); Mock <IRegionManager> regionManagerMock = new Mock <IRegionManager>(); regionManagerMock.Setup(x => x.RequestNavigate(RegionNames.MainContentRegion, new Uri("ComposeEmailView", UriKind.Relative))).Verifiable(); var viewModel = new InboxViewModel(emailServiceMock.Object, regionManagerMock.Object); viewModel.ComposeMessageCommand.Execute(null); regionManagerMock.VerifyAll(); }
public void WhenExecutingTheOpenCommand_ThenNavigatesToEmailView() { var email = new EmailDocument(); var emailServiceMock = new Mock <IEmailService>(); Mock <IRegionManager> regionManagerMock = new Mock <IRegionManager>(); regionManagerMock.Setup(x => x.RequestNavigate(RegionNames.MainContentRegion, new Uri(@"EmailView?EmailId=" + email.Id.ToString("N"), UriKind.Relative))).Verifiable(); var viewModel = new InboxViewModel(emailServiceMock.Object, regionManagerMock.Object); viewModel.OpenMessageCommand.Execute(email); regionManagerMock.VerifyAll(); }
//Get user unread messages public void Readmsg(String user, InboxViewModel model) { int total = 0; var FakeunRead = _userDateTime.Users.LastOrDefault(g => g.Id == user); var unRead = _userDateTime.msg.Where(f => f.receiverID == FakeunRead.Email); foreach (var unRead_ in unRead) { if (unRead_.isRead == 0) { total++; } } model.Read = total; }
//Get users deleted messages public void deletedMsg(String user, InboxViewModel model) { int total = 0; var deletedMsg = _userDateTime.Users.LastOrDefault(g => g.Id == user); var deletedMessage = _userDateTime.msg.Where(f => f.receiverID == deletedMsg.Email); foreach (var deletedMsg_ in deletedMessage) { if (deletedMsg_.isDeleted == 1) { total++; } } model.Deleted = total; }
public async Task <IActionResult> Index(int?id) { var identity = (ClaimsIdentity)this.User.Identity; var claim = identity.FindFirst(ClaimTypes.NameIdentifier); Message currentMessage; if (id != null) { currentMessage = await _context.Messages .Include(m => m.Messages) .Include(m => m.Writer) .Include(m => m.Receiver) .Where(m => m.ReceiverID == claim.Value || m.WriterID == claim.Value) .Where(m => m.ParentID == null) .FirstOrDefaultAsync(m => m.ID == id); } else { currentMessage = await _context.Messages .Include(m => m.Messages) .Include(m => m.Writer) .Include(m => m.Receiver) .Where(m => m.ReceiverID == claim.Value || m.WriterID == claim.Value) .Where(m => m.ParentID == null) .OrderByDescending(m => m.CreatedAt) .Take(1) .FirstOrDefaultAsync(); } if (currentMessage != null) { if (currentMessage.IsViewed != true) { currentMessage.IsViewed = true; await _context.SaveChangesAsync(); } } InboxViewModel inboxModel = new InboxViewModel() { Inbox = await _context.Messages.Where(i => i.ReceiverID == claim.Value || i.WriterID == claim.Value).Where(i => i.ParentID == null).Include(i => i.Writer).OrderByDescending(i => i.CreatedAt).ToListAsync(), Message = currentMessage }; return(View(inboxModel)); }
public ActionResult DETAILS() { int id = int.Parse(Request["MID"]); InboxViewModel model = new InboxViewModel(); ASSESMENTEntities3 ctx = new ASSESMENTEntities3(); var o = ctx.MailDetails.Where(u => u.MailID == id).FirstOrDefault(); MAilDetails ml = new MAilDetails(); ml.MailID = o.MailID; ml.MailForm = o.MailForm; ml.Subject1 = o.Subject1; ml.ReceiveDate = o.ReceiveDate; ml.Messsage = o.Messsage; return(View(ml)); }
// GET: Messages public async Task <IActionResult> Index() { if (User.Identity == null) { return(Unauthorized()); } if (!User.Identity.IsAuthenticated) { return(Unauthorized()); } var user = await userService.GetOrCreateAsync(this.User); var inboxViewModel = new InboxViewModel(await messageService.GetAllToUser(user).ToListAsync(), user); return(View(inboxViewModel)); }
public IActionResult Inbox() { DatingProfile profile = _context.DatingProfile.FirstOrDefault(id => id.UserAccountId == _userManager.GetUserId(User)); InboxViewModel inbox = new InboxViewModel(); inbox.mailMessages = _context.MailMessage.Where(to => to.ToProfileId == profile.Id).ToList(); List <DatingProfile> fromList = new List <DatingProfile>(); foreach (var msg in inbox.mailMessages) { fromList.Add(_context.DatingProfile.FirstOrDefault(from => from.Id == msg.FromProfileId)); } inbox.fromProfiles = fromList; return(View(inbox)); }
private void AddExecute(object o) { Inbox.Inbox inbox = new Inbox.Inbox(Application.Current.MainWindow); InboxViewModel inboxViewModel = new InboxViewModel(inbox); inbox.DataContext = inboxViewModel; bool?dialogResult = inbox.ShowDialog(); if (!dialogResult.HasValue || !dialogResult.Value) { return; } string text = inboxViewModel.Text; AddNewTimeStamp(text); }
public async Task <IActionResult> Inbox(int seen = 0, int page = 1) { var userId = this.User.GetId(); var notifications = await this.notificationService.GetAllByUserId(userId, seen, page, PageSize); var totalNotifications = await this.notificationService.TotalCountByCriteria(userId, seen, page, PageSize); var model = new InboxViewModel { CurrentPage = page, Notifications = notifications, TotalPages = (int)Math.Ceiling(totalNotifications / (double)PageSize), }; return(View(model)); }
//GET: Get inbox public ActionResult Messages(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ApplicationUser applicationUser = db.Users.Find(id); if (applicationUser == null) { return(HttpNotFound()); } InboxViewModel myModel = new InboxViewModel(); myModel.User = applicationUser; myModel.Messages = MessageDB.GetAllMessageForUserById(id); return(View(myModel)); }
//Get list of senders public void inbox(String user, InboxViewModel model) { var u = _userDateTime.Users.LastOrDefault(m => m.Id == user); List <Message> msg = new List <Message>(); List <Message> myMessage = _userDateTime.msg.Where(g => g.receiverID == u.Email && g.isDeleted == 0).ToList(); List <String> newList = new List <string>(); foreach (Message rececivedMsg in myMessage) { if (!newList.Contains(rececivedMsg.senderID)) { newList.Add(rececivedMsg.senderID); msg.Add(rececivedMsg); } } model.getMsg = msg; }
public ActionResult Process() { int id = int.Parse(Request["ID"]); InboxViewModel model = new InboxViewModel(); ASSESMENTEntities3 ctx = new ASSESMENTEntities3(); var obj = ctx.MailDetails.Where(u => u.UserID == id); foreach (var o in obj) { MailDetail ml = new MailDetail(); ml.MailID = o.MailID; ml.MailForm = o.MailForm; ml.Subject1 = o.Subject1; ml.ReceiveDate = o.ReceiveDate; ml.Messsage = o.Messsage; model.mlist.Add(ml); } return(View(model)); }
private void AddExecute(object o) { Inbox.Inbox inbox = new Inbox.Inbox(Application.Current.MainWindow); InboxViewModel inboxViewModel = new InboxViewModel(inbox); inbox.DataContext = inboxViewModel; bool?dialogResult = inbox.ShowDialog(); if (!dialogResult.HasValue || !dialogResult.Value) { return; } string text = inboxViewModel.Text; DateTime dateTime = DateTime.Now; Task newTask = new Task(dateTime, text); this.Tasks.Add(newTask); }
public async Task <IActionResult> Inbox(string?id) { var user = await userManager.FindByNameAsync(HttpContext.User.Identity.Name); // If the user clicked on a friend to open their chat if (id != null && user.Id != null) { var model = new InboxViewModel() { Chat = mumblrRepository.getChat(user.Id, id), UserFriends = mumblrRepository.getUserFriends(user.Id), SelectedFriend = id }; // Mark the messages as read var success = mumblrRepository.markMessagesAsRead(user.Id, id); // Verify that the database could handle the request if (success) { return(View(model)); } else { ViewBag.ErrorMessage = "There was an error processing the message. You may contact the admin via [email protected]"; return(View("NotFound")); } } // If the user has not clicked on a friend to open their chat yet else if (user.Id != null) { var model = new InboxViewModel() { UserFriends = mumblrRepository.getUserFriends(user.Id), }; return(View(model)); } ViewBag.ErrorMessage = "Request could not be handled. You may contact the admin via [email protected]"; return(View("NotFound")); }
/// <summary> /// Shows list of messages from a specific sender /// </summary> /// <param name="sendermail">E-mail address of sender</param> /// <returns>Messages from sender to user</returns> public ActionResult Index(String sendermail) { if (sendermail == null) { RedirectToAction("Index", "Senders"); } //Debug.WriteLine("REceived sendermail "+sendermail); //Debug.WriteLine("Sendermail length: "+sendermail.Length); string senderid = db.Users.Where(u => u.Email.Equals(sendermail)).Single().Id; string currentuser = User.Identity.GetUserId(); List <ReadEntry> readEntries = db.ReadEntries.Where(r => r.Receiver.Equals(currentuser) && r.Active && r.Message.Sender.Equals(senderid)).ToList <ReadEntry>(); int countDeleted = db.ReadEntries.Count(r => r.Receiver.Equals(currentuser) && !(r.Active)); List <MessageViewModel> messages = new List <MessageViewModel>(); foreach (ReadEntry entry in readEntries) { MessageViewModel viewmodel = MessageController.MessageToViewModel(entry.Message); if (entry.hasRead()) { viewmodel.Read = entry.FirstReadTime.ToString(); } else { viewmodel.Read = "[NEW]"; } if (viewmodel.TheMessage.Length > 15) { viewmodel.TheMessage = viewmodel.TheMessage.Substring(0, 10) + "..."; } if (viewmodel.Title.Length > 15) { viewmodel.Title = viewmodel.Title.Substring(0, 10) + "..."; } messages.Add(viewmodel); } messages.Reverse(); InboxViewModel inboxview = new InboxViewModel(messages, countDeleted); return(View(inboxview)); }