public IHttpActionResult createAppointment([FromBody] CreateAppointments entity) { try { if (entity == null) { ModelState.AddModelError("Entity", "First set the entity"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } appointmentsServices.createAppointment(Convert.ToDateTime(entity.assignmentDate), entity.patientId, entity.doctorId); return(Ok()); } catch (Exception e) { return(InternalServerError(e)); } }