Пример #1
0
        public ActionResult TaskDetails(int id)
        {
            var model    = new TaskVM();
            var mediator = new TaskMediator();

            model = mediator.GetTask(id);
            return(View("~/Views/Task/TaskDetail.cshtml", model));
        }
Пример #2
0
        public ActionResult Index(int id)
        {
            var mediator = new TaskMediator();
            var projects = mediator.GetAllTasks(id);

            ViewBag.ProjectId = id;
            return(View(projects));
        }
Пример #3
0
        public Task createNewTask(int ideaID, string desc)
        {
            TaskMediator mediator = new TaskMediator();
            Task         task     = new Task();

            task.taskID          = mediator.getLastID() + 1;
            task.ideaID          = ideaID;
            task.status          = "Not Done";
            task.taskDescription = desc;

            return(task);
        }
Пример #4
0
        public ActionResult EditTask(int id)
        {
            var mediator = new TaskMediator();

            ViewBag.ControllerAction = "EditTask";
            ViewBag.PageTitle        = "Edit Task";
            TaskVM taskModel = mediator.GetTask(id);
            var    uMediator = new UserMediator();

            taskModel.CompanyEmployees = uMediator.GetUsersByCompanyId();
            return(View("~/Views/Task/TaskForm.cshtml", taskModel));
        }
Пример #5
0
        private void executeBtn_Click(object sender, RoutedEventArgs e)
        {
            string ideaIDStr = ideaIDTxt.Text.Trim();
            string desc      = descTxt.Text.Trim();
            int    ideaID;

            bool success = int.TryParse(ideaIDStr, out ideaID);

            if (!success)
            {
                errorLbl.Text = "IdeaID must be a number!";
            }
            else if (desc == "")
            {
                errorLbl.Text = "Please input all field!";
            }
            else
            {
                IdeaMediator mediator = new IdeaMediator();
                Idea         idea     = mediator.getIdea(ideaID);
                if (idea.status != "Accepted")
                {
                    errorLbl.Text = "Idea can't be executed";
                }
                else
                {
                    TaskMediator tmediator = new TaskMediator();
                    TaskFactory  tfactory  = new TaskFactory();
                    Task         task      = tmediator.addTask(tfactory.createNewTask(ideaID, desc));
                    if (task == null)
                    {
                        MessageBox.Show("Execute idea failed!");
                    }
                    else
                    {
                        idea.status = "On Progress";
                        mediator.updateIdea(ideaID, idea);
                        if (idea.type == "Add")
                        {
                            AttractionRideMediator amediator = new AttractionRideMediator();
                            AttractionRideFactory  afactory  = new AttractionRideFactory();
                            amediator.addAttractionOrRide(afactory.createNewAttractionOrRide(idea.name, idea.category, idea.description));
                        }
                        MessageBox.Show("Execute idea success!");
                    }
                    refresh();
                }
            }
        }
Пример #6
0
        public ActionResult Report(int id)
        {
            var model    = new ReportVM();
            var list     = new List <Report>();
            var mediator = new TaskMediator();
            var tasks    = mediator.GetAllTasks(id);
            var blah     = tasks.GroupBy(g => g.Category);

            foreach (var key in blah)
            {
                var report = new Report();
                report.Category      = key.FirstOrDefault().Category;
                report.ExpendedHours = key.Sum(r => r.TaskHours);
                list.Add(report);
            }

            model.Category = list;
            return(View(model));
        }
Пример #7
0
        public ActionResult EditTask(TaskVM model)
        {
            var  mediator = new TaskMediator();
            bool success  = mediator.UpdateTask(model);

            if (success)
            {
                var url = string.Format("/task/index/{0}", model.ProjectId);
                return(Redirect(url));
            }
            else
            {
                var uMediator = new UserMediator();

                model.CompanyEmployees   = uMediator.GetUsersByCompanyId();
                ViewBag.ControllerAction = "EditTask";
                ViewBag.PageTitle        = "Edit Task";
                ModelState.AddModelError("ErrorMessage", "Unable to update Task");
                return(View("~/Views/Task/TaskForm.cshtml", model));
            }
        }
Пример #8
0
        public ActionResult CreateTask(TaskVM task)
        {
            var mediator = new TaskMediator();

            var success = mediator.CreateTask(task);

            if (success)
            {
                var url = string.Format("/task/index/{0}", task.ProjectId);
                return(Redirect(url));
            }
            else
            {
                var uMediator = new UserMediator();
                task.CompanyEmployees    = uMediator.GetUsersByCompanyId();
                ViewBag.ControllerAction = "CreateTask";
                ViewBag.PageTitle        = "Create Task";
                ModelState.AddModelError("ErrorMessage", "Unable to create task");
                return(View("~/Views/Task/TaskForm.cshtml", task));
            }
        }
Пример #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            TaskMediator mediator = new TaskMediator();

            taskView.ItemsSource = mediator.getAllTask();
        }