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));
        }
示例#2
0
        public IActionResult Delete(int id)
        {
            KWTask kwtask = taskRepo.GetKWTaskByID(id);

            if (kwtask != null)
            {
                var interaction = taskRepo.GetAssociatedInteraction(kwtask);
                if (interaction != null)
                {
                    interaction.Task           = null;
                    interaction.TaskForeignKey = null;
                    intRepo.UpdateInteraction(interaction);
                }

                taskRepo.DeleteKWTask(kwtask);
                return(RedirectToAction("AllKWTasks"));
            }
            else
            {
                ModelState.AddModelError("", "Task Not Found");
            }
            return(RedirectToAction("AllKWTasks"));
        }