public AllergyData InitializeAllergy(PostInitializeAllergyRequest request) { try { AllergyData result = null; IRestClient client = new JsonServiceClient(); //[Route("/{Version}/{ContractNumber}/Allergy/Initialize", "POST")] var url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Allergy/Initialize", DDAllergyUrl, "NG", request.Version, request.ContractNumber), request.UserId); PutInitializeAllergyDataResponse dataDomainResponse = client.Put <PutInitializeAllergyDataResponse>(url, new PutInitializeAllergyDataRequest { Context = "NG", ContractNumber = request.ContractNumber, AllergyName = request.AllergyName, UserId = request.UserId, Version = request.Version } as object); if (dataDomainResponse != null) { result = dataDomainResponse.AllergyData; } return(result); } catch (WebServiceException ex) { throw new WebServiceException("AD:InitializeAllergy()::" + ex.Message, ex.InnerException); } }
public DTO.Allergy InitializeAllergy(PostInitializeAllergyRequest request) { DTO.Allergy allergy = null; try { AllergyData data = EndpointUtil.InitializeAllergy(request); if (data != null) { allergy = Mapper.Map <DTO.Allergy>(data); } return(allergy); } catch (Exception ex) { throw ex; } }
public void InitializeAllergy_Test() { PostInitializeAllergyRequest request = new PostInitializeAllergyRequest { Context = context, ContractNumber = contractNumber, AllergyName = "New Allergy 2", UserId = userId, Version = version }; JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "Token", token)); //[Route("/{Version}/{ContractNumber}/Allergy/Initialize", "POST")] PostInitializeAllergyResponse response = client.Post <PostInitializeAllergyResponse>( string.Format("{0}/{1}/{2}/Allergy/Initialize", url, version, contractNumber), request); Assert.IsNotNull(response); }
public PostInitializeAllergyResponse Post(PostInitializeAllergyRequest request) { PostInitializeAllergyResponse response = new PostInitializeAllergyResponse(); ValidateTokenResponse result = null; try { if (base.Request != null) { 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.Allergy = AllergyManager.InitializeAllergy(request); } else { throw new UnauthorizedAccessException(); } } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); if ((ex is WebServiceException) == false) { AllergyManager.LogException(ex); } } finally { if (result != null) { string browser = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType; string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress; AuditUtil.LogAuditData(request, result.SQLUserId, null, browser, hostAddress, request.GetType().Name); } } return(response); }