コード例 #1
0
        public ActionResult GetDisabilities(double?lat, double?lng, double?radius, [FromQuery] string[] source,
                                            [FromQuery] string[] kind, [FromQuery] string[] tag, [FromQuery] string[] excludeTag,
                                            [FromQuery] string[] activity, [FromQuery] string[] weekdays, string gender = null,
                                            double?minCost = null, double?maxCost = null, string from = null, string to   = null,
                                            long?minTime   = null, long?maxTime   = null, long?minAge = null, long?maxAge = null)
        {
            #region Variable declaration or assignment
            lat    = lat ?? defaultLatitude;
            lng    = lng ?? defaultLongitude;
            radius = radius ?? defaultRadius;
            string sources     = null;
            string kinds       = null;
            string tags        = null;
            string excludeTags = null;
            string activities  = null;
            string days        = null;
            if (source.Length > 0)
            {
                sources = string.Join(",", source);
            }
            if (kind.Length > 0)
            {
                kinds = string.Join(",", kind);
            }
            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 (weekdays.Length > 0)
            {
                days = string.Join(",", weekdays);
            }
            #endregion
            var    oRequestCode = new Random().Next(0, int.MaxValue);
            var    oRequestTime = DateTime.Now;
            string Model        = string.Concat("{lat:", lat, ",lng:", lng, ",radius:", radius, ",sources:", sources, ",kinds:", kinds, ",tags:", tags, ",excludeTags:", excludeTags, ",activities:", activities, ",days:", days, ",gender:", gender, ",minCost:", minCost, ",maxCost:", maxCost, ",from:", from, ",to:", to, ",minTime:", minTime, ",maxTime:", maxTime, ",minAge:", minAge, ",maxAge:", maxAge, "}");
            var    disabilities = new List <string>();
            var    oResult      = MemoryCacheHelper.GetValue(Model + "-Disabilities");
            LogHelper.InsertServiceLogs("search/disabilities (GetDisabilities) (" + oRequestCode + ")", Model, oRequestTime);
            if (oResult == null)
            {
                disabilities = FeedHelper.GetDisabilities(lat, lng, radius, sources, kinds, tags,
                                                          excludeTags, activities, days,
                                                          minCost, maxCost, gender, minTime, maxTime,
                                                          minAge, maxAge, from, to);

                MemoryCacheHelper.Add(Model + "-Disabilities", disabilities, DateTimeOffset.UtcNow.AddHours(2));
            }
            else
            {
                disabilities = oResult as List <string>;
            }
            LogHelper.InsertServiceLogs("search/disabilities (GetDisabilities) - Response (" + oRequestCode + ")", Model, oRequestTime, DateTime.Now);
            return(Ok(new { items = disabilities }));
        }