using System; using System.Collections.Generic; using System.Linq; using System.Text.Json; using System.Threading.Tasks; public class CalendarService { private readonly OdooService _odooService; public CalendarService(OdooService odooService) { _odooService = odooService ?? throw new ArgumentNullException(nameof(odooService)); } /// /// Creates a calendar event. /// /// The event data to create. /// ID of the created event. public async Task CreateEventAsync(object eventData) { if (eventData == null) { throw new ArgumentNullException(nameof(eventData), "Event data cannot be null."); } return await _odooService.CreateAsync("calendar.event", eventData); } /// /// Deletes a calendar event based on event ID. /// /// The ID of the event to delete. /// True if deleted successfully, otherwise false. public async Task DeleteEventAsync(int eventId) { return await _odooService.DeleteAsync("calendar.event", eventId); } public async Task> GetEventsAsync(object filterData) { string[] fields = { "id", "name", "start", "stop", "user_id", "partner_ids" }; return await _odooService.SearchAsync("calendar.event", filterData, fields); } /// /// Updates an existing calendar event. /// /// The ID of the event to update. /// The data to update. /// True if the update was successful, otherwise false. public async Task UpdateMeetingAsync(int eventId, Dictionary updateData) { if (eventId <= 0) { throw new ArgumentException("Invalid event ID.", nameof(eventId)); } if (updateData == null || updateData.Count == 0) { throw new ArgumentNullException(nameof(updateData), "Update data cannot be null or empty."); } return await _odooService.UpdateAsync("calendar.event", eventId, updateData); } }