Ejemplo n.º 1
0
 public ActionResult Create(Appointment appointment)
 {
     if (ModelState.IsValid) {
         appointmentRepository.InsertOrUpdate(appointment);
         appointmentRepository.Save();
         return RedirectToAction("Index");
     } else {
         return View();
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
 public void InsertOrUpdate(Appointment appointment)
 {
     throw new NotImplementedException();
 }