public IActionResult DoAction(string id, string act)
        {
            int?uid = HttpContext.Session.GetInt32("uid");

            if (uid == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            int askId;

            if (!Int32.TryParse(id, out askId))
            {
                return(RedirectToAction("List", "AskForLeave"));
            }
            AskForLeave ask = AskForLeaveService.FindAskForLeaveById(askId);

            if (ask == null)
            {
                return(RedirectToAction("List", "AskForLeave"));
            }

            if (act.Equals("reject"))
            {
                AskForLeaveService.RejectAskForLeave(ask);
            }
            else if (act.Equals("approve"))
            {
                AskForLeaveService.AskFlowToNextSupervisor(ask);
            }
            return(RedirectToAction("Home", "Home"));
        }
        public IActionResult DoNew(string startTime, string endTime, string reason, string memo)
        {
            string result = "0";

            if (startTime == null ||
                endTime == null ||
                reason == null ||
                startTime.Trim().Equals("") ||
                endTime.Trim().Equals("") ||
                reason.Trim().Equals("")
                )
            {
                result = "Fields of 'From', 'To' and 'Reason' should be filled.";
                return(RedirectToAction("New", "AskForLeave", new { r = result }));
            }

            int?uid = HttpContext.Session.GetInt32("uid");

            DateTime st, et;

            if (!DateTime.TryParse(startTime, out st) || !DateTime.TryParse(endTime, out et))
            {
                result = "Time format not valid.";
                return(RedirectToAction("New", "AskForLeave", new { r = result }));
            }
            if (uid == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            Uzer u = UserService.FindUserByID((int)uid);

            AskForLeave ask = AskForLeaveService.AddAskForLeave(u, st, et, DateTime.Now, reason, memo);

            AskForLeaveService.AskFlowToNextSupervisor(ask);

            return(RedirectToAction("New", "AskForLeave", new { r = result }));
        }