public void CreateServiceType(Dtos.CreateServiceTypeInput input) { //We can use Logger, it's defined in ApplicationService class. //ERROR: Logger.Info("Creating a task for input: " + input); //Creating a new Task entity with given input's properties var type = new ServiceType { Code = input.Code, Description = input.Description }; //Saving entity with standard Insert method of repositories. _serviceTypeRepository.Insert(type); #region CreditsHero CriteriaValues var creditsHeroFormat = String.Format("{0}api/services/app/Criteria/AddCriteriaValue", System.Configuration.ConfigurationSettings.AppSettings["creditsHero:WebServiceApiPrefix"]); //var creditsHeroFormat = "http://creditshero.azurewebsites.net/api/services/cd/Criteria/AddCriteriaValue"; //var creditsHeroFormat = "http://localhost:6234/api/services/cd/Criteria/AddCriteriaValue"; var timelineUrl = string.Format(creditsHeroFormat); CreditsHero.Common.Dtos.CriteriaValuesDto criteriaOutput = new CreditsHero.Common.Dtos.CriteriaValuesDto(); //Serialize object to JSON MemoryStream jsonStream = new MemoryStream(); CreditsHero.Common.Dtos.CreateCriteriaValuesInput criteriaInput = new CreditsHero.Common.Dtos.CreateCriteriaValuesInput() { CreditCount = input.CreditCount, CriteriaRefId = input.CriteriaRefId, CriteriaValuesId = 0, Name = input.Description }; string jsonData = Newtonsoft.Json.JsonConvert.SerializeObject(criteriaInput); byte[] byteArray = Encoding.UTF8.GetBytes(jsonData); HttpWebRequest creditsHeroRequest = (HttpWebRequest)WebRequest.Create(timelineUrl); creditsHeroRequest.ContentType = "application/json;charset=utf-8"; creditsHeroRequest.ContentLength = byteArray.Length; creditsHeroRequest.Method = "POST"; Stream newStream = creditsHeroRequest.GetRequestStream(); newStream.Write(byteArray, 0, byteArray.Length); newStream.Close(); WebResponse timeLineResponse = creditsHeroRequest.GetResponse(); using (timeLineResponse) { using (var reader = new StreamReader(timeLineResponse.GetResponseStream())) { var results = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(reader.ReadToEnd()); criteriaOutput = new CreditsHero.Common.Dtos.CriteriaValuesDto(); } } #endregion }