public Dtos.GetRoofTypeOutput GetRoofTypes(CreditsHero.Common.Dtos.GetCriteriaInput input)
        {
            #region CreditsHero CriteriaValues
            var creditsHeroFormat = String.Format("{0}api/services/app/Criteria/GetCriteriaValues", System.Configuration.ConfigurationSettings.AppSettings["creditsHero:WebServiceApiPrefix"]);
            //var creditsHeroFormat = "http://creditshero.azurewebsites.net/api/services/cd/Criteria/GetCriteriaValues";
            //var creditsHeroFormat = "http://localhost:6234/api/services/cd/Criteria/GetCriteriaValues";
            var timelineUrl = string.Format(creditsHeroFormat);
            CreditsHero.Common.Dtos.GetCriteriaValuesOutput criteriaOutput = new CreditsHero.Common.Dtos.GetCriteriaValuesOutput();

            //Serialize object to JSON
            MemoryStream jsonStream = new MemoryStream();
            CreditsHero.Common.Dtos.GetCriteriaInput criteriaInput = new CreditsHero.Common.Dtos.GetCriteriaInput()
            {
                CompanyId  = input.CompanyId,
                CriteriaId = input.CriteriaId
            };
            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.CriteriaValues = new List <CreditsHero.Common.Dtos.CriteriaValuesDto>();
                    foreach (var item in results.result.criteriaValues)
                    {
                        criteriaOutput.CriteriaValues.Add(
                            Newtonsoft.Json.JsonConvert.DeserializeObject <CreditsHero.Common.Dtos.CriteriaValuesDto>(item.ToString()));
                    }
                }
            }
            #endregion

            //Called specific GetAllWithPeople method of task repository.
            var types = _roofTypeRepository.GetAll();

            List <Dtos.RoofTypeDto> roofTypes = new List <Dtos.RoofTypeDto>();

            roofTypes = new Dtos.GetRoofTypeOutput
            {
                RoofTypes = Mapper.Map <List <Dtos.RoofTypeDto> >(types)
            }.RoofTypes;

            //var mergeResults = criteriaOutput.CriteriaValues.Select(s => new Dtos.RoofTypeDto { Name = s.Name, Id = s.Id, CreditCount = s.CreditCount, CriteriaRefId = s.CriteriaRefId }).ToList();
            //mergeResults.AddRange(roofTypes.Select(s => new Dtos.RoofTypeDto{Name = s.Name, CreditCount = s.CreditCount, CriteriaRefId = s.CriteriaRefId, Id = s.Id, Code = s.Code, CreationTime = s.CreationTime, CreatorUserId = s.CreatorUserId, Description = s.Description, LastModificationTime = s.LastModificationTime, LastModifierUserId = s.LastModifierUserId}).ToList());
            //List<CreditsHero.Common.Dtos.CriteriaValuesDto> roofTypeList = roofTypes.Concat(criteriaOutput.CriteriaValues).ToList();

            var query = (from cv in criteriaOutput.CriteriaValues
                         from rt in roofTypes
                         where rt.Description == cv.Name
                         select new Dtos.RoofTypeDto
            {
                Code = rt.Code,
                CreationTime = rt.CreationTime,
                CreatorUserId = rt.CreatorUserId,
                Description = rt.Description,
                LastModificationTime = rt.LastModificationTime,
                LastModifierUserId = rt.LastModifierUserId,
                Id = cv.Id,
                CreditCount = cv.CreditCount,
                CriteriaRefId = cv.CriteriaRefId,
                Name = cv.Name
            }).ToList <Dtos.RoofTypeDto>();

            return(new Dtos.GetRoofTypeOutput()
            {
                RoofTypes = query
            });
            //roofTypeResults = roofTypeResults.Union(criteriaOutput.CriteriaValues);
        }
        public Dtos.GetRoofTypeOutput GetRoofTypes(CreditsHero.Common.Dtos.GetCriteriaInput input)
        {
            #region CreditsHero CriteriaValues
            var creditsHeroFormat = String.Format("{0}api/services/app/Criteria/GetCriteriaValues", System.Configuration.ConfigurationSettings.AppSettings["creditsHero:WebServiceApiPrefix"]);
            //var creditsHeroFormat = "http://creditshero.azurewebsites.net/api/services/cd/Criteria/GetCriteriaValues";
            //var creditsHeroFormat = "http://localhost:6234/api/services/cd/Criteria/GetCriteriaValues";
            var timelineUrl = string.Format(creditsHeroFormat);
            CreditsHero.Common.Dtos.GetCriteriaValuesOutput criteriaOutput = new CreditsHero.Common.Dtos.GetCriteriaValuesOutput();

            //Serialize object to JSON
            MemoryStream jsonStream = new MemoryStream();
            CreditsHero.Common.Dtos.GetCriteriaInput criteriaInput = new CreditsHero.Common.Dtos.GetCriteriaInput()
            {
                CompanyId = input.CompanyId,
                CriteriaId = input.CriteriaId
            };
            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.CriteriaValues = new List<CreditsHero.Common.Dtos.CriteriaValuesDto>();
                    foreach (var item in results.result.criteriaValues)
                    {
                        criteriaOutput.CriteriaValues.Add(
                            Newtonsoft.Json.JsonConvert.DeserializeObject<CreditsHero.Common.Dtos.CriteriaValuesDto>(item.ToString()));
                    }
                }
            }
            #endregion

            //Called specific GetAllWithPeople method of task repository.
            var types = _roofTypeRepository.GetAll();

            List<Dtos.RoofTypeDto> roofTypes = new List<Dtos.RoofTypeDto>();

            roofTypes = new Dtos.GetRoofTypeOutput
                         {
                             RoofTypes = Mapper.Map<List<Dtos.RoofTypeDto>>(types)
                         }.RoofTypes;

            //var mergeResults = criteriaOutput.CriteriaValues.Select(s => new Dtos.RoofTypeDto { Name = s.Name, Id = s.Id, CreditCount = s.CreditCount, CriteriaRefId = s.CriteriaRefId }).ToList();
            //mergeResults.AddRange(roofTypes.Select(s => new Dtos.RoofTypeDto{Name = s.Name, CreditCount = s.CreditCount, CriteriaRefId = s.CriteriaRefId, Id = s.Id, Code = s.Code, CreationTime = s.CreationTime, CreatorUserId = s.CreatorUserId, Description = s.Description, LastModificationTime = s.LastModificationTime, LastModifierUserId = s.LastModifierUserId}).ToList());
            //List<CreditsHero.Common.Dtos.CriteriaValuesDto> roofTypeList = roofTypes.Concat(criteriaOutput.CriteriaValues).ToList();

            var query = (from cv in criteriaOutput.CriteriaValues
                        from rt in roofTypes
                        where rt.Description == cv.Name
                        select new Dtos.RoofTypeDto
                        {
                            Code = rt.Code,
                            CreationTime = rt.CreationTime,
                            CreatorUserId = rt.CreatorUserId,
                            Description = rt.Description,
                            LastModificationTime = rt.LastModificationTime,
                            LastModifierUserId = rt.LastModifierUserId,
                            Id = cv.Id,
                            CreditCount = cv.CreditCount,
                            CriteriaRefId = cv.CriteriaRefId,
                            Name = cv.Name
                        }).ToList<Dtos.RoofTypeDto>();

            return new Dtos.GetRoofTypeOutput() { RoofTypes = query };
            //roofTypeResults = roofTypeResults.Union(criteriaOutput.CriteriaValues);
        }