Example #1
0
        /// <summary>
        /// The DeleteAppointment operation maps to HTTP DELETE method for deleting appointments.
        /// </summary>
        /// <param name="id">The appointment id</param>
        /// <returns>Success flag and Error message</returns>
        public ApiResponse DeleteAppointment(string id)
        {
            int         apptId;
            bool        success  = false;
            ApiResponse response = new ApiResponse();

            try
            {
                if (!String.IsNullOrEmpty(id))
                {
                    Int32.TryParse(id, out apptId);

                    if (apptId > 0)
                    {
                        success = AppointmentSchedulingServices.DeleteAppointment(apptId);
                    }
                }
            }
            catch (Exception e)
            {
                response.ErrorMessage = "Error deleting appointment --> " + e.Message.ToString();
            }
            finally
            {
                response.Success = success.ToString();
            }

            return(response);
        }
Example #2
0
        public void TestDeleteLastAppointment()
        {
            Appointment appt = new Appointment();

            try
            {
                List <Appointment> apptList = AppointmentSchedulingServices.GetAllAppointments();

                if (apptList != null && apptList.Count > 0)
                {
                    appt = apptList[apptList.Count - 1];

                    bool result = AppointmentSchedulingServices.DeleteAppointment(appt.ID);

                    Assert.IsTrue(result, "Appointment deleted.");
                }
                else
                {
                    Assert.Fail("Appointment List was Empty");
                }
            }
            catch (AssertFailedException)
            {
                throw;
            }
            catch (Exception ex)
            {
                Assert.Fail("Exception thrown --> " + ex.ToString());
            }
        }