コード例 #1
0
        public async Task <IActionResult> AddTask(int Id, List <int> idss, DateTime start, DateTime end, int managerId, bool success = false, bool invalid = false)
        {
            ViewBag.invalid   = invalid;
            ViewBag.Id        = Id;
            ViewBag.Success   = success;
            ViewBag.Employees = new SelectList(_repo2.GetEmployeesDropdown(idss), "Id", "Name");
            ViewBag.Projects  = new SelectList(await _repo.GetProjectsByManager(managerId), "Id", "Name");
            ViewBag.manager   = await _repo2.GetEmployeeNameById(managerId);

            var model = new Taskz()
            {
                ChooseStartDate  = start,
                ChooseEndDate    = end,
                StartDate        = start,
                EndDate          = end,
                ProjectManager   = ViewBag.manager,
                ProjectManagerId = managerId
            };

            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> GetProjectById(int id)
        {
            var data = await _repo.GetProjectById(id);


            if (data.DeliveryDate.Date.Subtract(DateTime.Now.Date).TotalDays <= 0)
            {
                ViewBag.TimePresentage = 0;
                ViewBag.TimeDays       = 0;
            }
            else if (data.StartDate.Date > DateTime.Now.Date)
            {
                ViewBag.TimePresentage = 100;
                ViewBag.TimeDays       = data.DeliveryDate.Date.Subtract(DateTime.Now.Date).TotalDays;
            }
            else
            {
                ViewBag.TimePresentage = Math.Round((data.DeliveryDate.Date.Subtract(DateTime.Now.Date).TotalDays) / (data.DeliveryDate.Date.Subtract(data.StartDate).TotalDays) * 100);
                ViewBag.TimeDays       = data.DeliveryDate.Date.Subtract(DateTime.Now.Date).TotalDays;
            }

            if (data.EstimetedBudget == 0)
            {
                ViewBag.BudgetRemaining  = 0;
                ViewBag.BudgetPresentage = 0;
            }
            else
            {
                ViewBag.BudgetRemaining  = data.EstimetedBudget - data.Cost;
                ViewBag.BudgetPresentage = Math.Round(((data.EstimetedBudget - data.Cost) / data.EstimetedBudget) * 100);
            }

            if (data.ContractValue == null || data.ContractValue == 0)
            {
                ViewBag.ProfitMargin       = 0;
                ViewBag.Profit             = 0;
                ViewBag.ProfitMarginTarget = 0;
            }
            else
            {
                ViewBag.ProfitMargin       = Math.Round((double)((data.ContractValue - data.Cost) / data.ContractValue * 100));
                ViewBag.Profit             = data.ContractValue - data.Cost;
                ViewBag.ProfitMarginTarget = Math.Round((double)((data.ContractValue - data.EstimetedBudget) / data.ContractValue * 100));
            }
            var totalTasks = await _repo2.TaskCount(data.Id);

            ViewBag.TotalTasks = totalTasks;
            if (totalTasks != 0)
            {
                ViewBag.Completion = Math.Round((double)((data.FinalizedTasks / totalTasks) * 100));
            }
            else
            {
                ViewBag.Completion = 0;
            }


            ViewBag.pm = await _repo2.GetEmployeeNameById(data.ProjectManagerId);

            if (data.CustomerId != null)
            {
                ViewBag.cus = await _repo3.GetCustomerNameById(data.CustomerId);
            }
            else
            {
                ViewBag.cus = "none";
            }

            return(View(data));
        }