public IEnumerable <Attendance> GetList(AttendanceParameter parameter) { var query = DB.Attendances.AsQueryable(); if (parameter.UserId.HasValue) { query = query.Where(e => e.UserId == parameter.UserId.Value); } if (parameter.BeginDate.HasValue) { query = query.Where(e => e.Date >= parameter.BeginDate.Value); } if (parameter.EndDate.HasValue) { query = query.Where(e => e.Date <= parameter.EndDate.Value); } return(query.OrderBy(e => e.Date)); }
public object Month(int year, int month) { var beginDate = new DateTime(year, month, 1); var endDate = beginDate.AddMonths(1); var parameter = new AttendanceParameter { BeginDate = beginDate, EndDate = endDate, UserId = Identity.ID }; var list = Core.AttendanceManager.GetList(parameter); var leaves = Core.FormInfoExtend1Manager.GetList(new Extend1Parameter { BeginTime = beginDate, EndTime = endDate, UserId = Identity.ID, PostUserId = Identity.ID, Result = true, }); return(new { list, logs = Core.AttendanceManager.GetLogs(new CheckInOutParameter { BeginTime = beginDate, EndTime = endDate, UserId = Identity.ID, }).Select(e => new { e.User.RealName, e.ID, e.UserId, e.UpdateTime, e.ApiContent, e.ApiResult, e.CreateTime, }), holiday = Core.HolidayManager.GetList(new HolidayParameter { BeginDate = beginDate, EndDate = endDate }), leaves = leaves.Select(e => new { e.Title, e.ScheduleBeginTime, e.ScheduleEndTime, e.Reason, e.Result, e.ID, e.CreateTime, e.Category, e.UserId, }), total = new { Normal = list.Count(e => e.AMResult == AttendanceResult.Normal || e.PMResult == AttendanceResult.Normal), Late = list.Count(e => e.AMResult == AttendanceResult.Late || e.PMResult == AttendanceResult.Late), Early = list.Count(e => e.AMResult == AttendanceResult.Early || e.PMResult == AttendanceResult.Early), Absent = list.Count(e => e.AMResult == AttendanceResult.Absent || e.PMResult == AttendanceResult.Absent), OfficialLeave = leaves.Count(e => e.Category == (int)LeaveType.Official), PersonalLeave = leaves.Count(e => e.Category == (int)LeaveType.Personal) }, time = new AttendanceTime(Core.AttendanceManager.GetAttendanceGroup(Identity.ID)) }); }