public ContentResult Save(int?id, FormCollection actionValues) { var action = new DataAction(actionValues); try { AppointmentViewModelFull appointmentViewModel = (AppointmentViewModelFull)DHXEventsHelper.Bind(typeof(AppointmentViewModelFull), actionValues); switch (action.Type) { case DataActionTypes.Insert: int patientID = int.Parse(sessionStateManger.getSecyrtaryActivePatinet(User.Identity.GetUserId())); appointmentViewModel.ClinicID = sessionStateManger.getClinecIDForCurrentSecurtary(User.Identity.GetUserId()); appointmentViewModel.PatientID = patientID; appointmentViewModel.Status = appointmentViewModel.Status; appointmentViewModel.text = "DR:" + doctorRepository.getDoctorNameByID(appointmentViewModel.DoctorID) + " Patient:" + patientRepository.getPatientNameByID(patientID); action.TargetId = appointmentRepository.AddNewAppointment(appointmentViewModel); break; case DataActionTypes.Delete: appointmentRepository.deleteAppointment(appointmentViewModel.id); break; default: appointmentRepository.alterAppointment(appointmentViewModel); break; } } catch { action.Type = DataActionTypes.Error; } return(Content(new AjaxSaveResponse(action), "text/xml")); }
public HttpResponseMessage Add() { try { System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.Body); string requestFromPost = reader.ReadToEnd(); var appointment = JsonConvert.DeserializeObject <AppointmentViewModel>(requestFromPost); // Calling update var response = _repository.AddNewAppointment(appointment); if (response) { return(new HttpResponseMessage(HttpStatusCode.OK)); } else { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } } catch (Exception) { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public string Booking(BookingViewModel booking) { try { long id = _appointmentRepository.AddNewAppointment(booking); _appointmentDetailRepository.AddAppointmentDetail(booking, id); return("Succeeded"); } catch (Exception ex) { return(ex.Message); } }