public static string GetExcelString(CustomTimeTrack reportObject, string reportName)
        {
            var propertiesToDisplayAsColumns = new Dictionary<string, string>
            {
                {"TotalTimeForTheDay", "Total Time Worked"},
                {"StampDateForDisplay", "Date"},
                {"EmployeeHourlyRate", "Hourly Rate"},
                {"EmployeePayForThePeriod", "Daily Payment"}
            };
            var builder = new StringBuilder();
            AddWorkBookHeader(builder);
            const int sheetCount = 1;

            var sheetName = reportName;//"Sheet(" + sheetCount + ")";
            //sheetName = reportName;

            AddWorkSheetHeader(builder, sheetName);
            AddWorkSheetColumn(builder, new DailyTimeTrack(), propertiesToDisplayAsColumns);
            AddWorkSheetData(builder, reportObject.EmployeeName, reportObject.DailyTimeTracks, propertiesToDisplayAsColumns);
            AddWorksheetFooter(builder);

            AddWorkBookFooter(builder);

            return builder.ToString().Trim();
        }
 public TimeTrackReportViewModel(CustomTimeTrack customTimeTrack, UserList userList)
 {
     CustomTimeTrack = customTimeTrack;
     UserList = userList;
 }
        public static CustomTimeTrack GetUserTimeTrackHistoryForSpecifiedPeriod(string userName, DateTime startDate, DateTime endDate)
        {
            var weekEndDateToSearchInDatabase = endDate.AddDays(1);

            var customTimeTrack = new CustomTimeTrack
            {
                CustomStartDate = startDate.Date,
                CustomEndDate = endDate.Date,
                UserName = userName,
                DailyTimeTracks = new List<DailyTimeTrack>()
            };

            using (var dbContext = new SchTimeTrackingEntities())
            {
                var currentUser = dbContext.UserProfiles.FirstOrDefault(c => c.UserName.ToLower().Equals(userName));

                customTimeTrack.EmployeeName = currentUser.FirstName + " " + currentUser.LastName;

                var userClockInOutTimings = (from utsh in dbContext.UserTimeTrackHistories
                                             where utsh.IsDeleted == false &&
                                               utsh.UserName.ToLower().Equals(userName.ToLower()) &&
                                               (utsh.StampDate >= startDate && utsh.StampDate < weekEndDateToSearchInDatabase) &&
                                               utsh.ClockInTime.Length > 0
                                             select utsh).ToList();

                if (userClockInOutTimings.Any())
                {
                    var currentDay = startDate.Date;

                    while (currentDay <= endDate.Date)
                    {
                        var dailyUserStampList =
                            userClockInOutTimings.Where(
                                daily =>
                                daily.StampDate >= currentDay && daily.StampDate < currentDay.AddDays(1)).ToList();

                        var dailyTimeTrack = new DailyTimeTrack(startDate, currentUser.HourlyRate.HasValue ? currentUser.HourlyRate.Value : 0)
                        {
                            StampDate = currentDay,
                            TimeTrackList =
                                GetTimeTrackList(dailyUserStampList, currentDay).
                                    OrderByDescending(c => c.ClockInTime).ThenByDescending(
                                        d => d.ClockOutTime).ToList()
                        };

                        customTimeTrack.DailyTimeTracks.Add(dailyTimeTrack);
                        customTimeTrack.DailyTimeTracks = customTimeTrack.DailyTimeTracks.OrderByDescending(c => c.StampDate).ToList();
                        currentDay = currentDay.AddDays(1);
                    }
                }
            }

            return customTimeTrack;
        }