public virtual IActionResult PostAddAppointmentDates(AppointmentDates model) { ResponceModel responceModel = new ResponceModel(); var appointmentData = _appointmentServices.GetAppointmentById(model.AppointmentMasterId); var appointmentDate = new AppointmentDates(); appointmentDate.AppointmentDate = model.AppointmentDate; appointmentDate.AppointmentMasterId = model.AppointmentMasterId; appointmentDate.AppointmentStatusId = (int)AppointmentStatus.Created; appointmentData.AppointmentDates.Add(appointmentDate); _appointmentServices.UpdateAppointment(appointmentData); responceModel.Success = true; responceModel.Message = "Create"; responceModel.AppointmentDateId = appointmentDate.Id; return(Json(responceModel)); }
public IActionResult Create(AppointmentModel model) { ResultModel resultModel = new ResultModel(); var AppointmentData = new AppointmentMaster(); try { if (ModelState.IsValid) { if (model.ID == 0) { AppointmentData.HospitalId = model.HospitalId; AppointmentData.PatientName = model.PatientName; AppointmentData.MR = model.MR; _appointmentServices.InsertAppointment(AppointmentData); SaveAppointmentDates(AppointmentData, model._appointmentDates); resultModel.Message = ValidationMessages.Success; resultModel.Status = 1; resultModel.Response = "Appointment Created"; return(Ok(resultModel)); } else { var appointmentData = _appointmentServices.GetAppointmentById(model.ID); appointmentData.Id = model.ID; appointmentData.HospitalId = model.HospitalId; appointmentData.PatientName = model.PatientName; appointmentData.MR = model.MR; _appointmentServices.UpdateAppointment(appointmentData); SaveAppointmentDates(appointmentData, model._appointmentDates); resultModel.Message = ValidationMessages.Success; resultModel.Status = 1; resultModel.Response = "Appointment Edited"; return(Ok(resultModel)); } } else { resultModel.Message = ValidationMessages.Failure; resultModel.Status = 0; resultModel.Response = "Appointment not created"; return(Ok(resultModel)); } } catch (Exception e) { _appointmentServices.DeleteAppointment(AppointmentData); return(Ok(model)); } }