예제 #1
0
 public ActionResult Create(Appointment appointment)
 {
     if (ModelState.IsValid) {
         appointmentRepository.InsertOrUpdate(appointment);
         appointmentRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
예제 #2
0
 // PUT /api/appointmentapi/5
 public HttpResponseMessage Put(int id, Appointment value)
 {
     if (ModelState.IsValid)
     {
         _appointmentRepository.InsertOrUpdate(value);
         _appointmentRepository.Save();
         return new HttpResponseMessage(HttpStatusCode.NoContent);
     }
     throw new HttpResponseException(HttpStatusCode.BadRequest);
 }
예제 #3
0
 public void InsertOrUpdate(Appointment appointment)
 {
     if (appointment.Id == default(int)) {
         // New entity
         context.Appointments.Add(appointment);
     } else {
         // Existing entity
         context.Entry(appointment).State = EntityState.Modified;
     }
 }
예제 #4
0
        // POST /api/appointmentapi
        public HttpResponseMessage Post(Appointment value)
        {
            if (ModelState.IsValid)
            {
                _appointmentRepository.InsertOrUpdate(value);
                _appointmentRepository.Save();

                //Created!
                //var response = new  HttpResponseMessage<Appointment>(value, HttpStatusCode.Created);
                var response = Request.CreateResponse<Appointment>(HttpStatusCode.Created, value);

                //Let them know where the new appointment is
                string uri = Url.Route(null, new { id = value.Id });
                response.Headers.Location = new Uri(Request.RequestUri, uri);

                return response;

            }
            throw new HttpResponseException(HttpStatusCode.BadRequest);
        }
예제 #5
0
 public void InsertOrUpdate(Appointment appointment)
 {
     throw new NotImplementedException();
 }