public async Task RunEmpScheduleReport() { string writePath = AppDomain.CurrentDomain.BaseDirectory + @"\EmployeeSchedule.csv"; var lookup = await _empScheduleReport.EmpScheduleLookup(); EmpSchedules.Clear(); foreach (var empSch in lookup) { EmpSchedules.Add(empSch); } using (StreamWriter file = new StreamWriter(writePath, false)) { string title = "Employee Schedule Report"; file.WriteLine(title); //Title file.WriteLine(DateTime.Now); //Timestamp file.WriteLine("Employee Name,Customer Name,PatrolStart,PatrolEnd"); //Headers foreach (EmpScheduleModel empSchedule in EmpSchedules) { file.WriteLine(empSchedule.EmployeeName + "," + empSchedule.CustomerName + "," + empSchedule.PatrolStart + "," + empSchedule.PatrolEnd); } file.Close(); MessageBox.Show(title + " successfuly created in " + AppDomain.CurrentDomain.BaseDirectory.ToString()); } }
public static void AddEmpSchedules(SchedulingDbContext schDBContext, EmpSchedules schedules) { try { schDBContext.EmpSchedules.Add(schedules); schDBContext.SaveChanges(); } catch (Exception ex) { throw ex; } }
public static void UpdateEmpSchedules(SchedulingDbContext schDBContext, EmpSchedules schedules) { try { schDBContext.EmpSchedules.Attach(schedules); schDBContext.Entry(schedules).Property(x => x.IsWorkingDay).IsModified = true; schDBContext.SaveChanges(); } catch (Exception ex) { throw ex; } }