Example #1
0
        public DataWrapper GetCarValueTrimsByEvalTypeByYearByMake([FromBody] string jsonString)
        {
            Dto.Query query;
            try { query = JsonConvert.DeserializeObject <Dto.Query>(jsonString); }
            catch { throw new HttpResponseException(HttpStatusCode.NotFound); }

            int year;

            if (!Int32.TryParse(query.Year, out year) || year < 1990 || year > DateTime.Now.AddMonths(6).Year)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }


            var modelTrims =
                EvaluationService.GetTrimsByYearByMakeByEvaluationType(year, query.Make, query.EvaluationType).ToList()
                .Select(m => new Dto.ModelTrims
            {
                Key   = m.Key,
                Value = m.Value
            }).ToList();

            return(DataWrapper(new { model_trims = modelTrims }, modelTrims.Count()));
        }