public void SaveAppointmentEntity(Appointment appointment) { if (!AllowServerPost) { return; } try { //because we set the custom field on response (triggering a call to change) //this will prevent another change being fired. AllowServerPost = false; StandardAppointment stdAppointment = UpdateEntityFromAppointment(appointment); StoreStandardAppointment store = new StoreStandardAppointment() { Appointment = stdAppointment.ConvertTo <StandardAppointmentDto>() }; StandardAppointmentResponse response = Context.ServiceClient.Post(store); appointment.CustomFields["ENTITY"] = response.Appointment.ConvertTo <StandardAppointment>(); if (response.ResponseStatus == null) { Context.ServiceClient.Post(new StandardAppointmentsNotification() { ClientGuid = Context.ClientInstanceGuid, FromUserName = Context.LoggedInUser.UserName, Selector = SelectorTypes.store, Ids = new List <int>() { response.Appointment.Id } }); } } catch (Exception) { AllowServerPost = true; throw; } finally { AllowServerPost = true; } }
/// <summary> /// Update or create a single StandardAppointment. /// </summary> /// <param name="request">The request containing the StandardAppointment that needs to be created or updated</param> /// <returns>The updated StandardAppointment will be returned.</returns> public virtual StandardAppointmentResponse Any(StoreStandardAppointment request) { //return ExecuteFaultHandledMethod(() => //{ StandardAppointmentResponse response = new StandardAppointmentResponse(); var _repository = _DataRepositoryFactory.GetDataRepository <IGenericEntityRepositoryBase <StandardAppointment, IDataContextNhJars> >(); //this fixes the references in case an appointment has exceptions ?? //foreach (var apptEx in request.Appointment.StandardAppointmentExceptions) //{ // apptEx.StandardAppointment = request.Appointment; //} StandardAppointment appt = request.Appointment.FromStandardAppointmentDto(); response.Appointment = _repository.CreateUpdate(appt, CurrentSessionUsername).ToStandardAppointmentDto(); return(response); //}); }