public List <CalendarModel> GetMaidTotalTimeSheet() { IEnumerable <string> values; if (Request.Headers.TryGetValues("Token", out values)) { var token = values.First(); var tokenModel = JsonConvert.DeserializeObject <TokenModel>(Encrypt.Base64Decode(token)); var maid = _service.GetActiveMaidById(tokenModel.Id); if (Equals(maid, null)) { ExceptionContent(HttpStatusCode.Unauthorized, "err_account_not_found"); } var startTime = ConvertDatetime.GetBeginMonthUnixTimeStampByTimestamp(maid.created_date); var endCurrentTime = ConvertDatetime.GetEndMonthUnixTimeStamp(); var result = new List <CalendarModel>(); while (startTime < endCurrentTime) { var endTime = ConvertDatetime.GetEndMonthUnixTimeStampByTimestamp(startTime); var apartmentEmployees = _service.GetListApartmentEmployeeByEmployeeIdAndTimeStamp(maid.employee_id, startTime, endTime).Select(p => new ApartmentEmployeeModel() { Id = p.apartment_employee_id, CheckInTime = p.check_in_time ?? 0, CheckOutTime = p.check_out_time ?? 0, Type = p.type, Apartment = new ApartmentModel() { Id = p.contract.apartment_id.Value, Code = p.contract.apartment.code, NoBedRoom = p.contract.no_bedroom } }).ToList(); var calendar = new CalendarModel() { Time = startTime, ApartmentEmployeeList = apartmentEmployees }; result.Add(calendar); startTime = endTime + 1; } return(result); } return(new List <CalendarModel>()); }