示例#1
0
        public object Get(GetTechnology request)
        {
            var key = ContentCache.TechnologyKey(request.Slug, clear: request.Reload);

            return(base.Request.ToOptimizedResultUsingCache(ContentCache.Client, key, () =>
            {
                int id;
                var tech = int.TryParse(request.Slug, out id)
                    ? Db.SingleById <Technology>(id)
                    : Db.Single <Technology>(x => x.Slug == request.Slug.ToLower());

                if (tech == null)
                {
                    throw HttpError.NotFound("Tech stack not found");
                }

                var techStacks = Db.Select(Db.From <TechnologyStack>()
                                           .Join <TechnologyChoice>()
                                           .Join <TechnologyChoice, Technology>()
                                           .Where <TechnologyChoice>(x => x.TechnologyId == tech.Id));

                return new GetTechnologyResponse
                {
                    Technology = tech,
                    TechnologyStacks = techStacks
                };
            }));
        }
示例#2
0
        public object Get(GetTechnology request)
        {
            if (string.IsNullOrEmpty(request.Slug))
            {
                throw new ArgumentNullException(nameof(request.Slug));
            }

            var tech = int.TryParse(request.Slug, out var id)
                ? Db.SingleById <Technology>(id)
                : Db.Single <Technology>(x => x.Slug == request.Slug.ToLower());

            if (tech == null)
            {
                throw HttpError.NotFound("Tech stack not found");
            }

            var techStacks = Db.Select(Db.From <TechnologyStack>()
                                       .Join <TechnologyChoice>()
                                       .Join <TechnologyChoice, Technology>()
                                       .Where <TechnologyChoice>(x => x.TechnologyId == tech.Id)
                                       .OrderByDescending(x => x.LastModified));

            return(new GetTechnologyResponse
            {
                Technology = tech,
                TechnologyStacks = techStacks
            });
        }
示例#3
0
        public async Task Can_proxy_to_techstacks_Async()
        {
            var client = new JsonServiceClient(ListeningOn.CombineWith("techstacks"));

            var request = new GetTechnology
            {
                Slug = "ServiceStack"
            };
            var response = await client.GetAsync(request);

            Assert.That(response.Technology.VendorUrl, Is.EqualTo("https://servicestack.net"));
        }
示例#4
0
 public object Any(GetTechnology request) => new GetTechnologyResponse();