Exemplo n.º 1
0
        public IActionResult BrokerDelete(int id)
        {
            Broker broker = brokerRepo.GetBrokerByID(id);

            if (broker != null)
            {
                brokerRepo.DeleteBroker(broker);
                return(RedirectToAction("Brokers"));
            }
            else
            {
                ModelState.AddModelError("", "Broker Not Found");
            }
            return(RedirectToAction("Home"));
        }
Exemplo n.º 2
0
        public IActionResult Archive(int id)
        {
            Broker broker = brokerRepo.GetBrokerByID(id);

            if (broker != null)
            {
                brokerRepo.ChangeStatus(broker, "Archived");
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("", "User Not Found");
            }
            return(RedirectToAction("Index", brokerRepo.GetAllBrokers().ToList()));
        }
Exemplo n.º 3
0
        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));
        }