コード例 #1
0
 public IActionResult UpdateTasks(InteractionVM vm)
 {
     foreach (KWTask t in vm.Tasks)
     {
         var task = taskRepo.GetKWTaskByID(t.KWTaskID);
         task.IsComplete = t.IsComplete;
         taskRepo.UpdateKWTask(task);
     }
     return(RedirectToAction("BrokerInteractions", new { BrokerID = vm.BrokerID }));
 }
コード例 #2
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));
        }
コード例 #3
0
        public ActionResult Edit(InteractionVM iVM, string taskAction = "")
        {
            var i = iVM.NewInteraction;

            if (i != null)
            {
                Interaction interaction = intRepo.GetInteractionById(i.InteractionID);

                if (iVM.Field == "Notes")
                {
                    interaction.Notes = i.Notes;
                }
                else if (iVM.Field == "NextStep")
                {
                    if (iVM.Task != null && taskAction == "New")
                    {
                        KWTask task = new KWTask()
                        {
                            AlertDate   = iVM.Task.AlertDate,
                            DateDue     = iVM.Task.DateDue,
                            Message     = iVM.Task.Message,
                            Priority    = iVM.Task.Priority,
                            DateCreated = iVM.Task.DateCreated
                        };
                        if (task.AlertDate == null)
                        {
                            task.Type = "Task";
                        }
                        else
                        {
                            task.Type = "Alert";
                        }

                        var profile = staffRepo.GetStaffProfileByFullName(Helper.StaffProfileLoggedIn.FirstName, Helper.StaffProfileLoggedIn.LastName);
                        profile.Tasks.Add(task);
                        taskRepo.AddKWTask(task);
                        interaction.Task = task;
                        task.Interaction = interaction;


                        taskRepo.UpdateKWTask(task);
                    }
                    else if (iVM.Task != null && taskAction == "Edit")
                    {
                        KWTask task = taskRepo.GetKWTaskByID(iVM.Task.KWTaskID);
                        task.Message   = iVM.Task.Message;
                        task.AlertDate = iVM.Task.AlertDate;
                        task.DateDue   = iVM.Task.DateDue;
                        task.Priority  = iVM.Task.Priority;

                        taskRepo.UpdateKWTask(task);
                    }
                    else
                    {
                        interaction.NextStep = i.NextStep;
                    }
                }
                else if (iVM.Field == "Date Created")
                {
                    interaction.DateCreated = i.DateCreated;
                }



                int verify = intRepo.UpdateInteraction(interaction); //Repository and broker.Interactions reflect proper values here
                if (verify == 1)
                {
                    //TODO add feedback of success
                    return(RedirectToAction("BrokerInteractions", new { BrokerID = iVM.BrokerID }));
                }
                else
                {
                    //TODO add feedback for error
                }
            }
            else
            {
                ModelState.AddModelError("", "Interaction Not Found");
            }

            return(RedirectToAction("BrokerInteractions", new { BrokerID = iVM.BrokerID }));
        }
コード例 #4
0
        public IActionResult UpdateTasks()
        {
            var vm = new InteractionVM();

            return(View(vm));
        }