public IActionResult AdminHome(string Page) { /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/ Helper.GetToday(); ViewBag.Critical = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList(); ViewBag.Page = Page; return(View()); }
//[Route("Index")] public IActionResult AllKWTasks(string filter) { /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/ Helper.GetToday(); var criticalVB = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList(); foreach (KWTask task in taskRepo.GetAllTasksByType("Task").Where(t => t.Priority == 5).ToList()) { criticalVB.Add(task); } ViewBag.Critical = criticalVB; ViewBag.Filter = filter; var vm = new KWTaskVM(); vm.StaffList = staffRepo.GetAllStaffProfiles().ToList(); var KWTasks = taskRepo.GetAllKWTasks().Where(t => t.Type != "Onboarding").ToList(); foreach (KWTask t in KWTasks.ToList()) { if (t.Priority == 5) { StaffProfile profile = staffRepo.GetProfileByTask(t); if (profile != null) { profile.Tasks.Remove(t); staffRepo.UpdateStaff(profile); } } foreach (StaffProfile s in vm.StaffList) { if (s.Tasks.Contains(t)) { t.StaffName = s.FirstName + " " + s.LastName; t.StaffEmail = s.Email; } } } vm.KWTasks = KWTasks; vm.NewKWTask = new KWTask(); return(View(vm)); }
public ViewResult AllBrokers() { /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/ Helper.GetToday(); var criticalVB = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList(); foreach (KWTask task in taskRepo.GetAllTasksByType("Task").Where(t => t.Priority == 5).ToList()) { criticalVB.Add(task); } ViewBag.Critical = criticalVB; var vm = new BrokerVM(); vm.Brokers = brokerRepo.GetAllBrokers().ToList(); vm.NewBroker = new Broker(); return(View(vm)); }
public IActionResult Index() { var criticalVB = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList(); foreach (KWTask task in taskRepo.GetAllTasksByType("Task").Where(t => t.Priority == 5).ToList()) { criticalVB.Add(task); } ViewBag.Critical = criticalVB; if (Helper.StaffProfileLoggedIn == null) { return(RedirectToAction("Login", "Auth")); } // TODO: Grab logged in user profile var me = Helper.DetermineProfile(profileRepo); // TODO: Send Staff Profile to View return(View(me)); }
public IActionResult BrokerInteractions(int BrokerID) { /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/ Helper.GetToday(); ViewBag.Critical = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList(); var broker = brokerRepo.GetBrokerByID(BrokerID); ViewBag.BrokerName = broker.FirstName + " " + broker.LastName; ViewBag.CurrentBrokerID = broker.BrokerID; ViewBag.StaffEmail = Helper.StaffProfileLoggedIn.Email; var allInteractions = broker.Interactions; //This is where the issue seems to present var vm = new InteractionVM(); vm.Interactions = allInteractions; vm.Broker = broker; vm.NewInteraction = new Interaction(); vm.AllBrokers = brokerRepo.GetAllBrokers().ToList(); vm.Task = new KWTask(); vm.TasksCompleted = 0; vm.AllStaff = staffRepo.GetAllStaffProfiles().ToList(); List <KWTask> tasks = new List <KWTask>(); foreach (KWTask t in broker.Requirements) { tasks.Add(t); if (t.IsComplete) { vm.TasksCompleted++; } } ViewBag.Percent = Math.Round((vm.TasksCompleted / 16) * 100); foreach (Interaction i in broker.Interactions) { if (i.TaskForeignKey != null) { tasks.Add(taskRepo.GetKWTaskByID((int)i.TaskForeignKey)); } } vm.Tasks = tasks; //TODO Ensure user is rerouted if not logged in return(View(vm)); }
public async Task <IActionResult> Index() { /*Login Logic*/ StaffUser user = await userManager.FindByNameAsync(User.Identity.Name); Helper.StaffUserLoggedIn = user; Helper.StaffProfileLoggedIn = Helper.DetermineProfile(staffProfRepo); /*End Login Logic*/ /*Call the GetToday method of the helper class to get and set today's date for use with datepicker validation*/ Helper.GetToday(); /* Priority reassignment Logic */ var tasks = taskRepo.GetAllKWTasks().Where(t => t.Type != "Onboarding"); foreach (KWTask t in tasks.ToList()) { int diff = (int)(t.DateDue - DateTime.Today).Value.TotalDays; if (diff < 0 && t.Priority < 5) { StaffProfile profile = staffProfRepo.GetProfileByTask(t); t.Priority = 5; taskRepo.UpdateKWTask(t); if (profile != null) { profile.Tasks.Remove(t); staffProfRepo.UpdateStaff(profile); } } else if (diff == 0 && t.Priority < 4) { t.Priority = 4; taskRepo.UpdateKWTask(t); } else if (diff <= 2 && t.Priority < 3) { t.Priority = 3; taskRepo.UpdateKWTask(t); } else if (diff == 3 && t.Priority < 2) { t.Priority = 2; taskRepo.UpdateKWTask(t); } } /*Display Alerts Logic*/ ViewBag.Name = Helper.StaffProfileLoggedIn.FirstName; ViewBag.Alerts = Helper.StaffProfileLoggedIn.Tasks.Where( t => t.Type == "Alert" && (DateTime.Compare(DateTime.Now, t.AlertDate.GetValueOrDefault()) == 0 || DateTime.Compare(DateTime.Now, t.AlertDate.GetValueOrDefault()) > 0)).ToList(); var criticalVB = taskRepo.GetAllTasksByType("Alert").Where(t => t.Priority == 5).ToList(); foreach (KWTask task in taskRepo.GetAllTasksByType("Task").Where(t => t.Priority == 5).ToList()) { criticalVB.Add(task); } ViewBag.Critical = criticalVB; /*End Display Alerts Logic*/ /*Populate ViewModel Logic*/ var vm = new HomeVM(); /*TODO Be aware this directly queries the database, may break if StaffProfile or KWTask models change*/ string sqlGlobal = "SELECT * FROM dbo.KWTasks WHERE StaffProfileID IS NULL"; string sqlPersonal = "SELECT * FROM dbo.KWTasks WHERE StaffProfileID = " + Helper.StaffProfileLoggedIn.StaffProfileID; vm.GlobalTasks = taskRepo.GetTasksFromSQL(sqlGlobal).Where(t => t.Type != "Onboarding").ToList(); vm.PersonalTasks = taskRepo.GetTasksFromSQL(sqlPersonal).Where(t => t.Type != "Onboarding").ToList(); List <Broker> brokers = new List <Broker>(); foreach (Interaction i in Helper.StaffProfileLoggedIn.Interactions) { foreach (Broker b in brokerRepo.GetAllBrokers()) { if (b.Interactions.Contains(i)) { i.BrokerName = b.FirstName + " " + b.LastName; if (!brokers.Contains(b)) { brokers.Add(b); } } } } ViewBag.Brokers = brokers; vm.PersonalInteractions = Helper.StaffProfileLoggedIn.Interactions; vm.NewTask = new KWTask(); vm.NewBroker = new Broker(); vm.NewMessage = new Message(); vm.StaffList = staffProfRepo.GetAllStaffProfiles().ToList(); /*End Populate ViewModel Logic*/ return(View(vm)); }