コード例 #1
0
        public ActionResult GetLocations(double?lat, double?lng, double?radius, [FromQuery] string[] activity,
                                         [FromQuery] string[] disabilitySupport, [FromQuery] string[] weekdays,
                                         [FromQuery] string[] source, [FromQuery] string[] tag, [FromQuery] string[] excludeTag,
                                         string gender = null, long?minTime   = null, long?maxTime   = null, long?minAge = null,
                                         long?maxAge   = null, long?page      = 1, long?limit        = 50, string from   = null,
                                         string to     = null, double?minCost = null, double?maxCost = null)
        {
            #region Variable declaration or assignment
            lat    = lat ?? defaultLatitude;
            lng    = lng ?? defaultLongitude;
            radius = radius ?? defaultRadius;
            var    oRadius            = radius?.ToString("f2");
            string sources            = null;
            string tags               = null;
            string excludeTags        = null;
            string activities         = null;
            string disabilitySupports = null;
            string days               = null;

            if (source.Length > 0)
            {
                sources = string.Join(",", source);
            }
            if (tag.Length > 0)
            {
                tags = string.Join(",", tag);
            }
            if (excludeTag.Length > 0)
            {
                excludeTags = string.Join(",", excludeTag);
            }
            if (activity.Length > 0)
            {
                activities = string.Join(",", activity);
            }
            if (disabilitySupport.Length > 0)
            {
                disabilitySupports = string.Join(",", disabilitySupport);
            }
            if (weekdays.Length > 0)
            {
                days = string.Join(",", weekdays);
            }
            if (page == null || page == 0)
            {
                page = 1;
            }
            if (limit == null || limit == 0)
            {
                limit = 50;
            }
            #endregion
            string Model        = string.Concat("{lat:", lat, ",lng:", lng, ",radius:", radius, ",sources:", sources, ",tags:", tags, ",excludeTags:", excludeTags, ",activitys:", activities, ",disabilitySupports:", disabilitySupports, ",days:", days, ",gender:", gender, ",minCost:", minCost, ",maxCost:", maxCost, ",from:", from, ",to:", to, ",page:", page, ",limit:", limit, ",minTime:", minTime, ",maxTime:", maxTime, ",minAge:", minAge, ",maxAge:", maxAge, "}");
            var    oRequestCode = new Random().Next(0, int.MaxValue);
            var    oRequestTime = DateTime.Now;
            LogHelper.InsertServiceLogs("search/locations (GetLocations) (" + oRequestCode + ")", Model, oRequestTime);
            var events = FeedHelper.GetLocations(lat, lng, radius, activities, disabilitySupports,
                                                 gender, minTime, maxTime, minAge, maxAge, days, page, limit,
                                                 from, to, sources, tags, excludeTags, minCost, maxCost);
            LogHelper.InsertServiceLogs("search/locations (GetLocations) - Response (" + oRequestCode + ")", Model, oRequestTime, DateTime.Now);
            return(Ok(events));
        }