public void ContactManager_UpdateCareTeamMember_ContactIdDoesNotExist_Should_Throw() { //Arrange var contactManager = new ContactManager(); var stubRequest = new UpdateCareTeamMemberRequest() { ContactId = "cid", CareTeamId = "careteamId", Id = "memberId", CareTeamMember = new Member() { ContactId = "memberCid", Id = "memberId", StatusId = 1, RoleId = "roleId" } }; var mockContactEndPointUtil = new Mock <IContactEndpointUtil>(); mockContactEndPointUtil.Setup(mceu => mceu.UpdateCareTeamMember(It.IsAny <UpdateCareTeamMemberRequest>())) .Returns(new UpdateCareTeamMemberResponse()); if (mockContactEndPointUtil.Setup(mcue => mcue.GetContactByContactId(It.IsAny <GetContactByContactIdRequest>())) == null) { } contactManager.EndpointUtil = mockContactEndPointUtil.Object; var mockCohortRulesProcessor = new Mock <ICohortRulesProcessor>(); contactManager.CohortRules = mockCohortRulesProcessor.Object; //Act var response = contactManager.UpdateCareTeamMember(stubRequest); //Assert. Assert.IsNotNull(response); mockContactEndPointUtil.Verify(mr => mr.UpdateCareTeamMember(It.IsAny <UpdateCareTeamMemberRequest>()), Times.Once); }
public void ContactManager_UpdateCareTeamMember_UnmatchedMemberId_Should_Throw() { var contactManager = new ContactManager(); var stubRequest = new UpdateCareTeamMemberRequest() { ContactId = "cid", CareTeamId = "careteamId", Id = "memberId", CareTeamMember = new Member() { Id = "memberId1", StatusId = 1 } }; contactManager.UpdateCareTeamMember(stubRequest); }
public void ContactManager_UpdateCareTeamMember_InCompleteMember_EmptyMemberContactId_Should_Throw() { var contactManager = new ContactManager(); var stubRequest = new UpdateCareTeamMemberRequest() { ContactId = "cid", CareTeamId = "careteamId", Id = "memberId", CareTeamMember = new Member() { StatusId = 1 } }; contactManager.UpdateCareTeamMember(stubRequest); }
public UpdateCareTeamMemberResponse Put(UpdateCareTeamMemberRequest request) { if (request == null) { throw new ArgumentNullException("request"); } var response = new UpdateCareTeamMemberResponse(); ValidateTokenResponse result = null; try { request.Token = base.Request.Headers["Token"] as string; result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber); if (result.UserId.Trim() != string.Empty) { request.UserId = result.UserId; response = ContactManager.UpdateCareTeamMember(request); } else { throw new UnauthorizedAccessException(); } } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); if ((ex is WebServiceException) == false) { ContactManager.LogException(ex); } } finally { if (result != null) { AuditHelper.LogAuditData(request, result.SQLUserId, null, System.Web.HttpContext.Current.Request, request.GetType().Name); } } return(response); }
public UpdateCareTeamMemberResponse UpdateCareTeamMember(UpdateCareTeamMemberRequest request) { UpdateCareTeamMemberResponse response = new UpdateCareTeamMemberResponse(); try { IRestClient client = new JsonServiceClient(); //[Route("/{Version}/{ContractNumber}/Contacts/{ContactId}/CareTeams/{CareTeamId}/CareTeamMembers/{Id}", "PUT")] string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Contacts/{4}/CareTeams/{5}/CareTeamMembers/{6}", DDContactServiceUrl, "NG", request.Version, request.ContractNumber, request.ContactId, request.CareTeamId, request.Id), request.UserId); var dataDomainResponse = client.Put <UpdateCareTeamMemberResponse>(url, new UpdateCareTeamMemberDataRequest { CareTeamMemberData = Mapper.Map <CareTeamMemberData>(request.CareTeamMember), Version = request.Version, ContactId = request.ContactId, CareTeamId = request.CareTeamId, Id = request.Id, ContractNumber = request.ContractNumber, Context = "NG" } as object); if (dataDomainResponse != null) { response.Version = dataDomainResponse.Version; response.Status = response.Status == null?new ResponseStatus() : dataDomainResponse.Status; } } catch (WebServiceException wse) { throw new WebServiceException("AD:UpdateCareTeamMember()::" + wse.Message, wse.InnerException); } return(response); }
public UpdateCareTeamMemberResponse UpdateCareTeamMember(UpdateCareTeamMemberRequest request) { var response = new UpdateCareTeamMemberResponse(); if (request == null) { throw new ArgumentNullException("request"); } if (request.CareTeamMember == null) { throw new ArgumentNullException("CareTeamMemberData is Null", "request"); } if (string.IsNullOrEmpty(request.ContactId)) { throw new ArgumentNullException("Null or empty ContactId", "request"); } if (string.IsNullOrEmpty(request.CareTeamId)) { throw new ArgumentNullException("Null or empty CareTeamId", "request"); } if (string.IsNullOrEmpty(request.Id)) { throw new ArgumentNullException("Null or empty MemberId", "request"); } if (request.Id != request.CareTeamMember.Id) { throw new ArgumentNullException("CareTeamMemberData.Id and Id are different", "request"); } var contact = GetContactByContactId(new GetContactByContactIdRequest { ContractNumber = request.ContractNumber, ContactId = request.ContactId, UserId = request.UserId, Version = request.Version }); if (contact == null) { throw new ApplicationException(string.Format("Contact with id: {0} does not exist", request.ContactId)); } var cohortRuleCheckData = new CohortRuleCheckData() { ContactId = request.ContactId, ContractNumber = request.ContractNumber, UserId = request.UserId, PatientId = contact.PatientId }; //Get the currentActiveCore TeamMember Id. string currentActiveCorePCMId = CohortRules.GetCareTeamActiveCorePCMId(cohortRuleCheckData); if (currentActiveCorePCMId != null && request.CareTeamMember.Core && currentActiveCorePCMId != request.Id & request.CareTeamMember.RoleId == Constants.PCMRoleId && request.CareTeamMember.StatusId == (int)CareTeamMemberStatus.Active) { throw new ArgumentNullException("Care Team already has an Active Core PCM", "request"); } ValidateCareTeamMemberFields(request.CareTeamMember); try { var domainResponse = EndpointUtil.UpdateCareTeamMember(request); if (domainResponse != null) { response.Status = domainResponse.Status; CohortRules.EnqueueCohorRuleCheck(cohortRuleCheckData); } } catch (Exception ex) { throw new Exception("AD:UpdateCareTeamMember()::" + ex.Message, ex.InnerException); } return(response); }
public UpdateCareTeamMemberResponse UpdateCareTeamMember(UpdateCareTeamMemberRequest request) { throw new NotImplementedException(); }