public List <Timesheet.Timesheet> GetTimesheets(string employeeToken) { TimesheetDS.EmployeeTimesheetsDataTable dt = new TimesheetDS.EmployeeTimesheetsDataTable(); TimesheetDSTableAdapters.EmployeeTimesheetsTableAdapter adapter = new TimesheetDSTableAdapters.EmployeeTimesheetsTableAdapter(); List <Timesheet.Timesheet> _tsList = new List <Timesheet.Timesheet>(); Guid employeeGUID = Guid.Parse(employeeToken); adapter.Fill(dt, employeeGUID); _tsList = dt.ToTimesheet(); return(_tsList); }
public ResponseData AddTimesheet(Timesheet.Timesheet tsPost) { TimesheetDS.EmployeeTimesheetsDataTable dt = new TimesheetDS.EmployeeTimesheetsDataTable(); TimesheetDSTableAdapters.EmployeeTimesheetsTableAdapter adapter = new TimesheetDSTableAdapters.EmployeeTimesheetsTableAdapter(); int id; bool IsFirstHalf = tsPost.quarter == 1 ? true : false; id = Convert.ToInt32(adapter.AddTimesheet(tsPost.employee.employeeToken, tsPost.month, tsPost.year, tsPost.totalhours, IsFirstHalf)); string TimesheetID = Convert.ToString(adapter.GetTimesheetID(id)); var response = new ResponseData { EmployeeToken = TimesheetID }; string TimesheetDayID; for (int i = 0; i < tsPost.days.Count(); i++) { id = Convert.ToInt32(adapter.AddTimesheetDay(Guid.Parse(TimesheetID), tsPost.days[i].date, tsPost.days[i].description.ToString())); TimesheetDayID = Convert.ToString(adapter.GetTimesheetDayID(id)); for (int x = 0; x < tsPost.days[0].hours.Count(); x++) { adapter.AddTimesheetHours(Guid.Parse(TimesheetDayID), Convert.ToDateTime(tsPost.days[i].hours[x].start), Convert.ToDateTime(tsPost.days[i].hours[x].end), (double)tsPost.days[i].hours[x].hours, (double)tsPost.days[i].hours[x].lunch); } } // Send Excel to Google Drive GoogleSheets _gs = new GoogleSheets(tsPost); //string monthName = new DateTime(tsPost.year, tsPost.month, 1).ToString("MMM", CultureInfo.InvariantCulture); //string empName = tsPost.employee.lastname.ToString() + ", " + tsPost.employee.lastname.ToString(); //string body = "Timesheet for " + tsPost.employee.lastname.ToString() + ", " + tsPost.employee.firstname.ToString() + " - " + monthName + " " + tsPost.year.ToString() + " " + "Period: " + tsPost.quarter.ToString(); //GoogleSheets _gs = new GoogleSheets(tsPost); //string fileTitle = _gs.fileTitle; //byte[] byteArray = System.IO.File.ReadAllBytes(@"C:\Users\Administrator\Desktop\Timesheet\TimesheetService_Deploy\bin\" + fileTitle + ".xls"); //MailAttachment attach = new MailAttachment(byteArray, fileTitle+".xls"); return(response); }