here is my event model
public class Event
{
[Key]
public string EventId { get; set; } // String ID for the event
public string Title { get; set; }
public string Description { get; set; }
public DateTime Date { get; set; }
[Required,ForeignKey("UserId")]
public string UserId { get; set; }
}
and here is my repository method:
public async Task AddEventAsync(Event newEvent)
{
if (newEvent.Date < DateTime.Now)
{
throw new InvalidOperationException(“Cannot create an event for a past date.”);
}
var userId = GetCurrentUserId();
newEvent.UserId = userId;
_context.Set().Add(newEvent);
await _context.SaveChangesAsync();
}
,yet when i create an event in the front end nothing save to the database