Beispiel #1
0
        public IHttpActionResult UpdateAppointmentBooking(int id, [FromBody] AppointmentBooking appointmentBooking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != appointmentBooking.AppointmentID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public IHttpActionResult GetAppointmentBooking(int id)
        {
            AppointmentBooking appointmentBooking = db.AppointmentBookings.Find(id);

            if (appointmentBooking == null)
            {
                return(NotFound());
            }

            return(Ok(appointmentBooking));
        }
Beispiel #3
0
        public IHttpActionResult AddAppointmentBooking([FromBody] AppointmentBooking appointmentBooking)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Debug.WriteLine(appointmentBooking);
            db.AppointmentBookings.Add(appointmentBooking);
            db.SaveChanges();

            return(Ok(appointmentBooking.AppointmentID));
        }
Beispiel #4
0
        public IHttpActionResult DeleteAppointmentBooking(int id)
        {
            AppointmentBooking appointmentBooking = db.AppointmentBookings.Find(id);

            if (appointmentBooking == null)
            {
                return(NotFound());
            }

            db.AppointmentBookings.Remove(appointmentBooking);
            db.SaveChanges();

            return(Ok(appointmentBooking));
        }
        public ActionResult Edit(int id, AppointmentBooking selectedBooking)
        {
            string      url     = "AppointmentBookingData/UpdateAppointmentBooking/" + id;
            HttpContent content = new StringContent(jss.Serialize(selectedBooking));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage httpResponse = client.PostAsync(url, content).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                return(RedirectToAction("Details", new { id = id }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        public ActionResult Create(AppointmentBooking NewAppointmentBooking)
        {
            NewAppointmentBooking.Confirmation = "0";
            string url = "AppointmentBookingData/AddAppointmentBooking";

            HttpContent content = new StringContent(jss.Serialize(NewAppointmentBooking));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            Debug.WriteLine(jss.Serialize(NewAppointmentBooking));
            HttpResponseMessage httpResponse = client.PostAsync(url, content).Result;

            if (httpResponse.IsSuccessStatusCode)
            {
                int BookingID = httpResponse.Content.ReadAsAsync <int>().Result;

                return(RedirectToAction("Details", new { id = BookingID }));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }