Beispiel #1
0
        //
        // GET: /Employee/Create

        public ActionResult Create()
        {
            var shifts = _shiftRepository.Get();

            ViewBag.Dept   = _deptRepository.Get();
            ViewBag.Branch = _branchRepository.Get();
            return(View(shifts));
        }
        // GET: Employee/Index/1
//        [Route("{controller}/Index/id")]
        public ActionResult Index(int id)
        {
            //TODO: Get by dept_id
            //TODO: "Back To list" on views add Dept_Id to link, Maybe pass it in Viewbag or smthng
            //TODO: DropDownList with Depts on create/Edit Employee
            //TODO: Fully debug Employee Views
            //TODO: Think about full trycatch removal
            //TODO: Add comments!
            Dept_Id          = id;
            ViewBag.DeptName = deptRepository.Get(Dept_Id).Name;
            return(View(employeeRepository.GetAll(id)));
        }
 public Dept Get(int id)
 {
     return(deptRepository.Get(id));
 }
Beispiel #4
0
 // GET: Dept/Edit/5
 public ActionResult Edit(int id)
 {
     return(View(deptRepository.Get(id)));
 }
        public ActionResult Index()
        {
            List <Department> departments = _deptRepository.Get();

            return(View(departments));
        }
        public ActionResult Index(string from, string to, int shiftId = 0, int deptId = 0, int branchId = 0)
        {
            var events    = _eventLogRepository.Get();
            var employees = _employeeRepository.Get();
            var shifts    = _shiftRepository.Get();
            var depts     = _deptRepository.Get();
            var branches  = _branchRepository.Get();

            ViewBag.Shifts      = shifts;
            ViewBag.Departments = depts;
            ViewBag.Branches    = branches;

            var query = _attendanceService.GetUserAttendance(events, employees);
            List <Attendance> result;

            query = shiftId != 0 ? query.Where(_ => _.Shift.Id == shiftId) : query;
            query = deptId != 0 ? query.Where(_ => _.Department.Id == deptId) : query;
            query = branchId != 0 ? query.Where(_ => _.Branch.Id == branchId) : query;
            DateTime fromDate, toDate;

            if (from != null && DateTime.TryParse(from, out fromDate))
            {
                query = query.Where(_ => _.Date >= fromDate);
            }
            if (to != null && DateTime.TryParse(to, out toDate))
            {
                query = query.Where(_ => _.Date <= toDate);
            }

            var filterResult = query.ToList();
            var numberOfLeavesTakenByEmployee = _leaveCountRepository.GetLeaveCount(query);
            var leaveCountDictionary          = numberOfLeavesTakenByEmployee.ToDictionary(l => l.EmployeeId);
            var groupByUser         = filterResult.GroupBy(_ => _.UserId);
            var attendanceSummaries = new List <AttendanceSummary>();

            foreach (var g in groupByUser)
            {
                var totalPresents = g.Count();
                var totalLates    = g.Count(day => TimeSpan.Compare(day.FirstEntryTime.TimeOfDay,
                                                                    TimeSpan.Parse(day.Shift.GraceEntryTime).Add(TimeSpan.FromMinutes(1))) == 1);
                totalPresents -= totalLates;
                var totalDays = totalPresents + totalLates;
                if (leaveCountDictionary.Count > 0 && leaveCountDictionary.ContainsKey(g.FirstOrDefault().Employee.Id))
                {
                    attendanceSummaries.Add(new AttendanceSummary
                    {
                        Name                  = g.FirstOrDefault().Name,
                        TotalDays             = (int)totalDays,
                        TotalPresents         = totalPresents,
                        TotalLates            = totalLates,
                        ReamainingCasualLeave = leaveCountDictionary[g.FirstOrDefault().Employee.Id].CasualLeave,
                        ReamainingEarnLeave   = leaveCountDictionary[g.FirstOrDefault().Employee.Id].EarnLeave,
                        ReamainingSickLeave   = leaveCountDictionary[g.FirstOrDefault().Employee.Id].SickLeave
                    });
                }
                else
                {
                    attendanceSummaries.Add(new AttendanceSummary
                    {
                        Name                  = g.FirstOrDefault().Name,
                        TotalDays             = (int)totalDays,
                        TotalPresents         = totalPresents,
                        TotalLates            = totalLates,
                        ReamainingCasualLeave = 0,
                        ReamainingEarnLeave   = 0,
                        ReamainingSickLeave   = 0
                    });
                }
            }

            return(View(attendanceSummaries.OrderBy(_ => _.Name).ToList()));
        }