Exemple #1
0
        public async Task <IActionResult> SelectResources(SelectEmployees emp)
        {
            if ((emp.StartDate < DateTime.Now) || (emp.EndDate < DateTime.Now))
            {
                return(RedirectToAction(nameof(SelectResources), new { currentContext = true }));
            }
            if (emp.StartDate >= emp.EndDate)
            {
                return(RedirectToAction(nameof(SelectResources), new { invalid = true }));
            }


            var ids = await _repo2.SelectResources(emp);

            return(RedirectToAction(nameof(GetResources), new { idss = ids }));
        }
Exemple #2
0
        public async Task <IActionResult> SelectEmployee(SelectEmployees emp)
        {
            if ((emp.StartDate < DateTime.Now) || (emp.EndDate < DateTime.Now))
            {
                return(RedirectToAction(nameof(SelectEmployee), new { currentContext = true }));
            }
            if (emp.StartDate >= emp.EndDate)
            {
                return(RedirectToAction(nameof(SelectEmployee), new { invalid = true }));
            }


            var ids = await _repo2.SelectEmployees(emp);

            return(RedirectToAction(nameof(AddTask), new { managerId = emp.ProjectManagerId, idss = ids, start = emp.StartDate, end = emp.EndDate }));
        }
Exemple #3
0
        public async Task <IActionResult> AddTask(Taskz task)
        {
            if ((task.ChooseStartDate < DateTime.Now) || (task.ChooseEndDate < DateTime.Now) || (task.ChooseStartDate >= task.ChooseEndDate))
            {
                var emp1 = new SelectEmployees()
                {
                    StartDate = task.StartDate,
                    EndDate   = task.EndDate
                };
                var ids1 = await _repo2.SelectEmployees(emp1);

                return(RedirectToAction(nameof(AddTask), new { invalid = true, idss = ids1, start = emp1.StartDate, end = emp1.EndDate }));
            }

            if (ModelState.IsValid)
            {
                int id = await _repo2.AddTask(task);

                if (id > 0)
                {
                    var emp = new SelectEmployees()
                    {
                        StartDate        = task.ChooseStartDate,
                        EndDate          = task.ChooseEndDate,
                        ProjectManagerId = task.ProjectManagerId
                    };
                    var ids = await _repo2.SelectEmployees(emp);

                    return(RedirectToAction(nameof(AddTask), new { Id = id, idss = ids, start = emp.StartDate, end = emp.EndDate, success = true, managerId = task.ProjectManagerId }));
                }
            }

            var emp2 = new SelectEmployees()
            {
                StartDate        = task.ChooseStartDate,
                EndDate          = task.ChooseEndDate,
                ProjectManagerId = task.ProjectManagerId
            };
            var ids2 = await _repo2.SelectEmployees(emp2);

            ViewBag.Employees = (new SelectList(_repo2.GetEmployeesDropdown(ids2), "Id", "Name"));
            ViewBag.Projects  = new SelectList(await _repo.GetCurrentProjects(), "Id", "Name");
            return(View());
        }