public async Task <IActionResult> PutAppointment(int id, Appointment appointment) { if (id != appointment.ID) { return(BadRequest()); } appointment.StartDate = appointment.StartDate.Date; appointment.EndDate = appointment.EndDate.Date; _context.Entry(appointment).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AppointmentExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutCustomer(int id, Customer customer) { if (id != customer.ID) { return(BadRequest()); } _context.Entry(customer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Calendar> > DeleteCalendar(string calendarName) { var calendar = await _context.Calendars.FirstOrDefaultAsync(x => x.CalendarName == calendarName); if (calendar == null) { return(NotFound()); } _context.Calendars.Remove(calendar); await _context.SaveChangesAsync(); return(calendar); }