public JsonResult PostData(Appointment appointment) { Appointment dataAppointment = new Appointment(); dataAppointment.Date = appointment.Date; dataAppointment.DoctorId = appointment.DoctorId; dataAppointment.PatientId = appointment.PatientId; dataAppointment.ServiceTypeId = appointment.ServiceTypeId; dataAppointment.RoomId = appointment.RoomId; dataAppointment.Status = Statuses.Reservado.ToString(); if (appointment.Id > 0) { dataAppointment.UpdatedBy = User.Identity.GetUserId(); dataAppointment.UpdatedDate = DateTime.Today; dataAppointment.Id = appointment.Id; db.Update(dataAppointment); } else { dataAppointment.CreatedBy = User.Identity.GetUserId(); dataAppointment.CreatedDate = DateTime.Today; db.Add(dataAppointment); } return(Json("success", JsonRequestBehavior.AllowGet)); }
public AddAppointmentResponse add(AddAppointmentRequest request) { try { var response = new AddAppointmentResponse(); var bc = new AppointmentComponent(); response.Result = bc.Add(request.Appointment); return(response); } catch (Exception ex) { var httpError = new HttpResponseMessage() { StatusCode = (HttpStatusCode)422, ReasonPhrase = ex.Message }; throw new HttpResponseException(httpError); } }