public async Task SeedAsync(TimetableContext context) { if (!context.Appointments.Any()) { await context.Appointments.AddRangeAsync(GetAppointments()); await context.SaveChangesAsync(); } }
public async Task <IActionResult> CreateAppointment([FromBody] Appointment appointment) { if (appointment == null) { return(BadRequest()); } var item = new Appointment { Title = appointment.Title, Description = appointment.Description, Location = appointment.Location, CreationDate = DateTime.Now, StartDate = appointment.StartDate, Duration = appointment.Duration }; await _context.Appointments.AddAsync(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetAppointment), new { id = item.Id }, null)); }