public GetAllCommModesDataResponse GetAllCommModes(GetAllCommModesDataRequest request) { GetAllCommModesDataResponse response = new GetAllCommModesDataResponse(); ILookUpRepository repo = Factory.GetRepository(request, RepositoryType.LookUp); List <IdNamePair> data = repo.GetAllCommModes(); if (data != null) { response.CommModes = data; } return(response); }
public void GetAllCommModes_Test() { // Arrange double version = 1.0; string contractNumber = "InHealth001"; string context = "NG"; IRestClient client = new JsonServiceClient(); JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "x-Phytel-UserID", "531f2df9072ef727c4d2a3df")); // Act GetAllCommModesDataResponse response = client.Get <GetAllCommModesDataResponse> (string.Format("{0}/{1}/{2}/{3}/CommModes", "http://localhost:8888/LookUp/", context, version, contractNumber)); // Assert Assert.AreNotEqual(0, response.CommModes.Count); }
public List <IdNamePair> GetModes() { Uri modesUri = new Uri(string.Format("{0}/LookUp/{1}/{2}/{3}/commmodes?UserId={4}", Url, Context, Version, ContractNumber, HeaderUserId)); HttpClient modesClient = GetHttpClient(modesUri); GetAllCommModesDataRequest modesRequest = new GetAllCommModesDataRequest { Version = Version, Context = Context, ContractNumber = ContractNumber }; DataContractJsonSerializer modesJsonSer = new DataContractJsonSerializer(typeof(GetAllCommModesDataRequest)); MemoryStream modesMs = new MemoryStream(); modesJsonSer.WriteObject(modesMs, modesRequest); modesMs.Position = 0; //use a Stream reader to construct the StringContent (Json) StreamReader modesSr = new StreamReader(modesMs); StringContent modesContent = new StringContent(modesSr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json"); modesMs.Dispose(); //Post the data var modesResponse = modesClient.GetStringAsync(modesUri); var modesResponseContent = modesResponse.Result; string modesResponseString = modesResponseContent; GetAllCommModesDataResponse responseModes = null; using (var modesMsResponse = new MemoryStream(Encoding.Unicode.GetBytes(modesResponseString))) { var modesSerializer = new DataContractJsonSerializer(typeof(GetAllCommModesDataResponse)); responseModes = (GetAllCommModesDataResponse)modesSerializer.ReadObject(modesMsResponse); } return(responseModes.CommModes); }
public void GetAllCommModes_Test() { // Arrange double version = 1.0; string contractNumber = "InHealth001"; string context = "NG"; GetAllCommModesDataRequest request = new GetAllCommModesDataRequest { Context = context, ContractNumber = contractNumber, Version = version }; // Act LookUpDataManager lm = new LookUpDataManager { Factory = new LookUpRepositoryFactory() }; GetAllCommModesDataResponse response = lm.GetAllCommModes(request); // Assert Assert.AreNotEqual(0, response.CommModes.Count); }
public GetAllCommModesDataResponse Get(GetAllCommModesDataRequest request) { GetAllCommModesDataResponse response = new GetAllCommModesDataResponse(); try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("LookUpDD:Get()::Unauthorized Access"); } response = LookUpDataManager.GetAllCommModes(request); response.Version = request.Version; } catch (Exception ex) { CommonFormatter.FormatExceptionResponse(response, base.Response, ex); string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } return(response); }