Пример #1
0
        public List <Traffic> GetTrafficByCriteria(GetTrafficByCriteriaDto getTrafficByCriteriaDto)
        {
            string getAllTrafficStoredProcedure = "GetTrafficByCriteria";

            List <SqlParameter> parametersList = new List <SqlParameter>
            {
                new SqlParameter {
                    ParameterName = "@minAge", Value = getTrafficByCriteriaDto.MinAge
                },
                new SqlParameter {
                    ParameterName = "@maxAge", Value = getTrafficByCriteriaDto.MaxAge
                },
                new SqlParameter {
                    ParameterName = "@gender", Value = getTrafficByCriteriaDto.Gender
                },
                new SqlParameter {
                    ParameterName = "@startDate", Value = getTrafficByCriteriaDto.MinDateTime
                },
                new SqlParameter {
                    ParameterName = "@endDate", Value = getTrafficByCriteriaDto.MaxDateTime
                }
            };

            DataTable dataTable = ExecuteQuery(getAllTrafficStoredProcedure, parametersList);

            List <Traffic> trafficList = new List <Traffic>();

            foreach (DataRow row in dataTable.Rows)
            {
                trafficList.Add(MapTraffic(row));
            }

            return(trafficList);
        }
Пример #2
0
        public static string GetTraffic(string ageRange, string gender, string minDate, string maxDate)
        {
            DateTime minDateTime = DateTime.ParseExact(minDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            DateTime maxDateTime = DateTime.ParseExact(maxDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);

            string[] ageRanges = ageRange.Split(';');

            List <Traffic> trafficList = new List <Traffic>();

            for (int i = 0; i < ageRanges.Length; i++)
            {
                int minAge = int.Parse(ageRanges[i].Split('-')[0]);
                int maxAge = int.Parse(ageRanges[i].Split('-')[1]);

                GetTrafficByCriteriaDto getTrafficByCriteriaDto = new GetTrafficByCriteriaDto
                {
                    MinAge      = minAge,
                    MaxAge      = maxAge,
                    Gender      = gender,
                    MinDateTime = minDateTime,
                    MaxDateTime = maxDateTime
                };
                trafficList.AddRange(new BaseController().GetTrafficByCriteria(getTrafficByCriteriaDto));
            }

            return(JsonConvert.SerializeObject(trafficList));
        }
Пример #3
0
        public List <Traffic> GetTrafficByCriteria(GetTrafficByCriteriaDto getTrafficByCriteriaDto)
        {
            List <Traffic> trafficList = new TrafficDao().GetTrafficByCriteria(getTrafficByCriteriaDto);

            return(trafficList);
        }