Пример #1
0
        public IHttpActionResult PutAppointment(int id, Appointment appointment){

            if (!ModelState.IsValid) {
                return BadRequest(ModelState);
            }

            if (id != appointment.appointment_id) {
                return BadRequest();
            }

            db.Entry(appointment).State = EntityState.Modified;

            try {
                db.SaveChanges();
            } catch (DbUpdateConcurrencyException) {
                if (!AppointmentExists(id)) {
                    return NotFound();
                }else{
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Пример #2
0
 public async Task<IHttpActionResult> PostAppointment(AppointmentsVM appointmentVM)
 {
     if (!ModelState.IsValid)
     {
         return BadRequest(ModelState);
     }
    Appointment appointment = new Appointment();
     appointment.appointment_reason = appointmentVM.Reason;
     appointment.appointment_date = DateTime.Parse(appointmentVM.Time);
     appointment.appointment_notes = appointmentVM.Notes;
     appointment.appointment_duration = appointmentVM.Duration;
     appointment.appointment_id = 0;
     db.Appointments.Add(appointment);
     await db.SaveChangesAsync();
     return CreatedAtRoute("appointmetPost", new { id = appointment.appointment_id }, appointment);
 }