public async Task <IActionResult> MarkInvalid(string id) { try { await _emailService.ChangeStatusAsync(id, EmailStatus.Invalid); _logger.LogInformation(string.Format(Constants.LogEmailInvalid, User.Identity.Name, id)); TempData[Constants.TempDataMsg] = Constants.EmailInvalidSucc; var allEmails = new List <EmailDto>(); allEmails = await _emailService.GetAllEmailsAsync(); var vm = new AllEmailsViewModel { AllEmails = allEmails.Select(x => x.MapToViewModel()).ToList(), ActiveTab = Constants.TabAll }; return(RedirectToAction("Index", "Email")); } catch (Exception ex) { return(ErrorHandle(ex)); } }
public async Task <IActionResult> GetOpenEmails(string sortOrder) { try { var openEmails = await _emailService.GetOpenEmailsAsync(); ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; ViewData["SinceStatus"] = sortOrder == "SinceStatus_Date" ? "sinceStatus_date_desc" : "SinceStatus_Date"; switch (sortOrder) { case "Date": openEmails = openEmails.OrderBy(mail => mail.Received).ToList(); break; case "date_desc": openEmails = openEmails.OrderByDescending(mail => mail.Received).ToList(); break; case "SinceStatus_Date": openEmails = openEmails.OrderBy(mail => mail.ToCurrentStatus).ToList(); break; case "sinceStatus_date_desc": openEmails = openEmails.OrderByDescending(mail => mail.ToCurrentStatus).ToList(); break; default: openEmails = openEmails.OrderByDescending(mail => mail.ToCurrentStatus).ToList(); break; } var apps = await _appService.GetOpenAppsAsync(); var vm = new AllEmailsViewModel { AllEmails = openEmails.Select(mail => mail.MapToViewModel()).ToList(), ActiveTab = Constants.TabOpen }; foreach (var emailVM in vm.AllEmails) { emailVM.OperatorUsername = await _appService.GetOperatorUsernameAsync(emailVM.Id); emailVM.ApplicationId = await _appService.GetAppIdByMailIdAsync(emailVM.Id); } return(View(Constants.PageIndex, vm)); } catch (Exception ex) { return(ErrorHandle(ex)); } }
public async Task <IActionResult> GetNewEmails(string sortOrder) { try { var newEmails = await _emailService.GetNewEmailsAsync(); ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; ViewData["SinceStatus"] = sortOrder == "SinceStatus_Date" ? "sinceStatus_desc" : "SinceStatus_Date"; switch (sortOrder) { case "Date": newEmails = newEmails.OrderBy(mail => mail.Received).ToList(); break; case "date_desc": newEmails = newEmails.OrderByDescending(mail => mail.Received).ToList(); break; case "SinceStatus_Date": newEmails = newEmails.OrderBy(mail => mail.ToCurrentStatus).ToList(); break; case "sinceStatus_desc": newEmails = newEmails.OrderByDescending(mail => mail.ToCurrentStatus).ToList(); break; default: newEmails = newEmails.OrderByDescending(mail => mail.ToCurrentStatus).ToList(); break; } var vm = new AllEmailsViewModel { AllEmails = newEmails.Select(mail => mail.MapToViewModel()).ToList(), ActiveTab = Constants.TabNew }; return(View(Constants.PageIndex, vm)); } catch (Exception ex) { return(ErrorHandle(ex)); } }
public async Task <IActionResult> Index(string sortOrder) { try { var allEmails = await _emailService.GetAllEmailsAsync(); ViewData["DateSortParm"] = sortOrder == "Date" ? "date_desc" : "Date"; switch (sortOrder) { case "Date": allEmails = allEmails.OrderBy(mail => mail.Received).ToList(); break; case "date_desc": allEmails = allEmails.OrderByDescending(mail => mail.Received).ToList(); break; default: allEmails = allEmails.OrderByDescending(mail => mail.Received).ToList(); break; } var vm = new AllEmailsViewModel { AllEmails = allEmails.Select(x => x.MapToViewModel()).ToList(), ActiveTab = Constants.TabAll }; return(View(Constants.PageIndex, vm)); } catch (Exception ex) { return(ErrorHandle(ex)); } }