Beispiel #1
0
        public HttpResponseMessage AddAppointmentImportance(AppointmentImportance appointmentImportance)
        {
            try
            {
                if (appointmentImportance == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
                }

                AppointmentImportance addedAppointmentImportance = appointmentImportanceRepository.AddAppointmentImportance(appointmentImportance);
                return(Request.CreateResponse(HttpStatusCode.Created, addedAppointmentImportance));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
            }
        }
Beispiel #2
0
        public IActionResult AddAppointmentType(AppointmentType appointmentType)
        {
            try
            {
                if (appointmentType == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                AppointmentType addedAppointmentType = appointmentTypeRepository.AddAppointmentType(appointmentType);
                return(StatusCode(StatusCodes.Status201Created, addedAppointmentType));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
Beispiel #3
0
        public HttpResponseMessage UpdateAppointmentImportance(int importanceId, AppointmentImportance tmpAppointmentImportance)
        {
            try
            {
                if (tmpAppointmentImportance == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
                }

                tmpAppointmentImportance.importanceId = importanceId;
                AppointmentImportance updatedAppointmentImportance = appointmentImportanceRepository.UpdateAppointmentImportance(tmpAppointmentImportance);
                return(Request.CreateResponse(HttpStatusCode.OK, updatedAppointmentImportance));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
            }
        }
Beispiel #4
0
        public IActionResult UpdateAppointmentType(int appointmentTypeId, AppointmentType appointmentType)
        {
            try
            {
                if (appointmentType == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                appointmentType.appointmentTypeId = appointmentTypeId;
                AppointmentType updatedAppointmentType = appointmentTypeRepository.UpdateAppointmentType(appointmentType);
                return(Ok(updatedAppointmentType));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }
        public HttpResponseMessage UpdateAppointment(int appointmentId, Appointment appointment)
        {
            try
            {
                if (appointment == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, errors));
                }

                appointment.appointmentId = appointmentId;
                Appointment updatedAppointment = appointmentRepository.UpdateAppointment(appointment);
                return(Request.CreateResponse(HttpStatusCode.OK, updatedAppointment));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors));
            }
        }