public IActionResult Create(int?EmployeeId)
        {
            if (HttpContext.Session.GetString("id") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (HttpContext.Session.GetString("user") == "Admin")
            {
                return(RedirectToAction("Index", "Admin"));
            }
            Employee emp = _db.Employees.Find(EmployeeId);

            if (emp == null)
            {
                return(NotFound());
            }
            ViewBag.Teams     = _db.Teams.ToList();
            ViewBag.ShowLogin = false;
            Task t = new Task
            {
                EmployeeId = emp.EmployeeId,
                Employee   = emp
            };

            return(View(t));
        }
        public double BussinessDays(Task ob)
        {
            DateTime endD             = Convert.ToDateTime(ob.EndDate);
            DateTime startD           = Convert.ToDateTime(ob.StartDate);
            double   calcBusinessDays = 1 + ((endD - startD).TotalDays * 5 -
                                             (startD.DayOfWeek - endD.DayOfWeek) * 2) / 7;

            if (endD.DayOfWeek == DayOfWeek.Saturday)
            {
                calcBusinessDays--;
            }
            if (startD.DayOfWeek == DayOfWeek.Sunday)
            {
                calcBusinessDays--;
            }
            return(calcBusinessDays);
        }
Exemple #3
0
        public IActionResult TaskDetails(int?id)
        {
            if (HttpContext.Session.GetString("id") == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (HttpContext.Session.GetString("user") == "Employee")
            {
                return(RedirectToAction("Index", "Employee", new { id = HttpContext.Session.GetString("id") }));
            }
            Task ob = _db.Tasks.Find(id);

            if (ob == null)
            {
                return(NotFound());
            }
            ViewBag.ShowLogin = false;
            return(View(ob));
        }