public static async Task PostAsync(HttpContext context) { //var todo = await context.Request.ReadJsonAsync<BookingInfo>(_options); var todojson = await context.Request var db = new BookingsDBContext(); await db.BookingInfo.AddAsync(todo); await db.SaveChangesAsync(); }
public static async Task DeleteAsync(HttpContext context) { //if (!context.Request.RouteValues.TryGet("id", out int id)) if (!context.Request.RouteValues.ContainsKey("id")) { context.Response.StatusCode = 400; return; } int id = (int)context.Request.RouteValues["id"]; var db = new BookingsDBContext(); var todo = await db.BookingInfo.FindAsync(id); if (todo == null) { context.Response.StatusCode = 404; return; } db.BookingInfo.Remove(todo); await db.SaveChangesAsync(); }