Esempio n. 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));
            }
        }
Esempio n. 2
0
        public IActionResult AddAppointmentImportance(AppointmentImportance appointmentImportance)
        {
            try
            {
                if (appointmentImportance == null)
                {
                    return(BadRequest("Data is null."));
                }
                if (!ModelState.IsValid)
                {
                    Errors errors = ErrorsHelper.GetErrors(ModelState);
                    return(BadRequest(errors));
                }

                AppointmentImportance addedAppointmentImportance = appointmentImportanceRepository.AddAppointmentImportance(appointmentImportance);
                return(StatusCode(StatusCodes.Status201Created, addedAppointmentImportance));
            }
            catch (Exception ex)
            {
                Errors errors = ErrorsHelper.GetErrors(ex);
                return(StatusCode(StatusCodes.Status500InternalServerError, errors));
            }
        }