using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
public class AttendanceService
{
private readonly OdooService _odooService;
public AttendanceService(OdooService odooService)
{
_odooService = odooService ?? throw new ArgumentNullException(nameof(odooService));
}
///
/// Records attendance for an employee.
///
/// The attendance data to record.
/// ID of the created attendance record.
public async Task RecordAttendanceAsync(object attendanceData)
{
if (attendanceData == null)
{
throw new ArgumentNullException(nameof(attendanceData), "Attendance data cannot be null.");
}
return await _odooService.CreateAsync("hr.attendance", attendanceData);
}
///
/// Records attendance for an employee.
///
/// The attendance data to record.
/// ID of the created attendance record.
public async Task MarkAsAbsentAsync(object absenceData)
{
if (absenceData == null)
{
throw new ArgumentNullException(nameof(absenceData), "Attendance data cannot be null.");
}
return await _odooService.CreateAsync("hr.attendance", absenceData);
}
// Method to delete attendance record for a given employee and date
public async Task DeleteAttendanceAsync(int employeeId, DateTime date)
{
// Prepare the filter data to search for the attendance record
var filterData = new
{
domain = new List