public UpdateExternalPractitionerResponse UpdateExternalPractitioner(UpdateExternalPractitionerRequest request) { var prac = PersistenceContext.Load <ExternalPractitioner>(request.PractitionerDetail.PractitionerRef, EntityLoadFlags.CheckVersion); EnsureNoDeactivatedContactPointsWithActiveOrders(request.PractitionerDetail.ContactPoints); var assembler = new ExternalPractitionerAssembler(); assembler.UpdateExternalPractitioner(request.PractitionerDetail, prac, PersistenceContext); prac.MarkEdited(); var userCanVerify = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.ExternalPractitionerVerification); if (request.MarkVerified && userCanVerify) { prac.MarkVerified(); } return(new UpdateExternalPractitionerResponse(assembler.CreateExternalPractitionerSummary(prac, PersistenceContext))); }
public AddExternalPractitionerResponse AddExternalPractitioner(AddExternalPractitionerRequest request) { var prac = new ExternalPractitioner(); var assembler = new ExternalPractitionerAssembler(); assembler.UpdateExternalPractitioner(request.PractitionerDetail, prac, PersistenceContext); prac.MarkEdited(); var userCanVerify = Thread.CurrentPrincipal.IsInRole(AuthorityTokens.Admin.Data.ExternalPractitionerVerification); if (request.MarkVerified && userCanVerify) { prac.MarkVerified(); } PersistenceContext.Lock(prac, DirtyState.New); // ensure the new prac is assigned an OID before using it in the return value PersistenceContext.SynchState(); return(new AddExternalPractitionerResponse(assembler.CreateExternalPractitionerSummary(prac, PersistenceContext))); }