Esempio n. 1
0
        public static void DailyCheckDelegation()
        {
            List <staff_representative> delelist = StaffRepData.GetAllNotExpired().ToList();

            foreach (staff_representative rep in delelist)
            {
                string datetoday = DateTime.Today.Date.ToString("yyyy-MM-dd");

                if (rep.start_date.Equals(datetoday))
                {
                    StaffRepData.StartDelegation(rep.representative_staff_obj.staffId);
                }
                if (rep.end_date.Equals(datetoday))
                {
                    StaffRepData.EndDelegation(rep.representative_staff_obj.staffId);;
                }
            }
        }
Esempio n. 2
0
        public ActionResult Delegate_Authority_Staff(FormCollection form_data)
        {
            string staff_name      = form_data["staff_list"];
            string duty_start_date = form_data["start_date_box"].ToString();
            string duty_end_date   = form_data["end_date_box"].ToString();

            List <staff_representative> list = StaffRepData.GetAllNotExpired();

            foreach (staff_representative st in list)
            {
                if (StaffData.GetStaffById(st.staff_representativeId).name.Equals(staff_name))
                {
                    return(RedirectToAction("Delegate_Authority", "Head"));
                }
            }

            using (var db = new DataBaseContext())
            {
                staff staff_obj = db.staff_repository.Where(s => s.name == staff_name).FirstOrDefault();

                staff_representative staff_representative_obj = new staff_representative(duty_start_date, duty_end_date, staff_obj, "Pending");

                db.staff_representative_repository.Add(staff_representative_obj);
                db.SaveChanges();

                if (duty_start_date.Equals(DateTime.Today.Date.ToString("yyyy-MM-dd")))
                {
                    StaffRepData.StartDelegation(staff_obj.staffId);
                }
            }



            //Email Notification
            staff  sta      = StaffData.GetStaffByName(staff_name);
            string emailadd = sta.email;
            Task   task     = Task.Run(() => {
                EmailNotification.SendNotificationEmailToEmployee(emailadd, "New Delegation Reminder", "Your were just be delegated as temporary department head, please check it out.");
            });

            return(RedirectToAction("Delegate_Authority", "Head"));
        }
Esempio n. 3
0
        //----------------------------------------------------------------------------------------
        // ---------------------------- DELEGATE AUTHORITY ---------------------------------------
        public ActionResult Delegate_Authority()
        {
            using (var db = new DataBaseContext())
            {
                String username = Session["UserName"].ToString();

                staff staff_obj = db.staff_repository.Where(s => s.name == username).Select(x => x).FirstOrDefault();

                string department_name = staff_obj.department_obj.department_name;

                List <staff> staff_lis = db.staff_repository.Where(s => s.department_obj.department_name == department_name && (s.position == "Employee" || s.position == "Representative")).ToList();

                ViewBag.Dept_name = department_name;
                ViewBag.Staff_lis = staff_lis;


                ViewBag.Staff_Representative = StaffRepData.GetAllNotExpired();
            }
            return(View());
        }