コード例 #1
0
        public SaveCareTeamDataResponse Post(SaveCareTeamDataRequest request)
        {
            var response = new SaveCareTeamDataResponse()
            {
                Version = request.Version
            };

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ContactDD:CareTeamService:Post()::Unauthorized Access");
                }

                response = Manager.InsertCareTeam(request);
            }
            catch (Exception ex)
            {
                CommonFormat.FormatExceptionResponse(response, base.Response, ex);

                var aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }
コード例 #2
0
        public SaveCareTeamDataResponse SaveCareTeam(SaveCareTeamRequest request)
        {
            SaveCareTeamDataResponse response = null;

            try
            {
                IRestClient client = new JsonServiceClient();
                // '/{Context}/{Version}/{ContractNumber}/Contacts/{ContactId}/CareTeams
                var url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Contacts/{4}/CareTeams",
                                                               DDContactServiceUrl,
                                                               "NG",
                                                               request.Version,
                                                               request.ContractNumber, request.ContactId), request.UserId);
                response =
                    client.Post <SaveCareTeamDataResponse>(url, new SaveCareTeamDataRequest
                {
                    CareTeamData   = Mapper.Map <CareTeamData>(request.CareTeam),
                    Version        = request.Version,
                    ContactId      = request.ContactId,
                    ContractNumber = request.ContractNumber,
                    Context        = "NG"
                } as object);
            }
            catch (WebServiceException wse)
            {
                throw new WebServiceException("AD:SaveCareTeam()::" + wse.Message, wse.InnerException);
            }

            return(response);
        }
コード例 #3
0
ファイル: Importer.cs プロジェクト: rotovibe/engage
        public SaveCareTeamDataResponse InsertCareTeam(SaveCareTeamDataRequest request)
        {
            //[Route("/{Context}/{Version}/{ContractNumber}/Contacts/{ContactId}/CareTeams", "POST")]
            Uri contactUri = new Uri(string.Format("{0}/Contact/{1}/{2}/{3}/Contacts/{4}/CareTeams?UserId={5}",
                                                   Url,
                                                   Context,
                                                   Version,
                                                   ContractNumber,
                                                   request.ContactId,
                                                   HeaderUserId));
            HttpClient client = GetHttpClient(contactUri);

            DataContractJsonSerializer jsonSer = new DataContractJsonSerializer(typeof(SaveCareTeamDataRequest));

            // use the serializer to write the object to a MemoryStream
            MemoryStream ms = new MemoryStream();

            jsonSer.WriteObject(ms, request);
            ms.Position = 0;

            //use a Stream reader to construct the StringContent (Json)
            StreamReader sr = new StreamReader(ms);

            StringContent theContent = new StringContent(sr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json");

            ms.Dispose();

            //Post the data
            var response        = client.PostAsync(contactUri, theContent);
            var responseContent = response.Result.Content;

            string responseString = responseContent.ReadAsStringAsync().Result;
            SaveCareTeamDataResponse saveCareTeamDataResponse = null;

            using (var msResponse = new MemoryStream(Encoding.Unicode.GetBytes(responseString)))
            {
                var serializer = new DataContractJsonSerializer(typeof(SaveCareTeamDataResponse));
                saveCareTeamDataResponse = (SaveCareTeamDataResponse)serializer.ReadObject(msResponse);
            }

            return(saveCareTeamDataResponse);
        }
コード例 #4
0
        public SaveCareTeamDataResponse InsertCareTeam(SaveCareTeamDataRequest request)
        {
            var response = new SaveCareTeamDataResponse();

            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var repo = _factory.GetCareTeamRepository(request, RepositoryType.CareTeam);

            if (repo == null)
            {
                throw new Exception("Repository is null");
            }

            var careTeam = repo.Insert(request) as CareTeamData;

            response.CareTeamData = careTeam;

            return(response);
        }