コード例 #1
0
        // Step NA: Returns the LOCData, based on iterating the results from the ResultsTables
        private LOCData GetV1(string search)
        {
            // Step: Return data form using the ResultsTables property
            var resultsTable = ExperienceITDB.ResultsTables.AsEnumerable();
            // Step: Filter based on the title containing the search value
            var dbresults = resultsTable.Where(x => x.Title.Contains(search));
            var data      = new LOCData();
            var results   = new List <Result>();

            foreach (var dbItem in dbresults)
            {
                var item = new Result();
                item.title     = dbItem.Title;
                item.createdOn = dbItem.CreateDate;
                item.image     = new Image()
                {
                    full   = "https://dummyimage.com/275x275/aaaaaa/000000.jpg&text=" + item.title,
                    square = "https://dummyimage.com/75x75/cccccc/000000.jpg&text=" + item.title
                };
                item.links = new Links()
                {
                    item     = "https://dummyimage.com/75x75/aaaaaa/000000.jpg&text=link:" + item.title,
                    resource = "https://dummyimage.com/275x275/aaaaaa/000000.jpg&text=link:" + item.title
                };
                results.Add(item);
            }
            data.results = results;
            return(data);
        }
コード例 #2
0
        public LOCData GetFromQueryString([FromUri] LOCRequest location)
        {
            var data = new LOCData();

            data.results = Reader(location.query);
            return(data);
        }
コード例 #3
0
        // Step 8.60 Returns the LOCData, based on using LINQ
        private LOCData Get(string search)
        {
            // This will create a variable db that contains the entity information.
            using (var db = new ExperienceITDatabaseEntities())
            {
                // Step 8.61: Iterate the ResultsTables.
                var resultList = db.ResultsTables
                                 // Step 8.62: Filter based on the title containing the search value
                                 //Student: Update Code Here.
                                 .Where(x => true)
                                 // Step 8.63: transform the data from ResultsTable  to Result
                                 .Select <ResultsTable, Result>
                                     (t => new Result
                {
                    //Student: Insert Code Here.
                })
                                 .ToList(); // Converts to a list

                // This will return the resultList, and place it in an LOCData object.
                var data = new LOCData()
                {
                    results = resultList
                };
                throw new NotImplementedException();
                return(null);
            }
        }
コード例 #4
0
        public LOCData GetFromQueryString([FromUri] LOCRequest location)
        {
            var search = location.query;
            // Step 6.60: Return the LOCData object, with sample data
            var data = new LOCData();

            data.results = new List <Result>
            {
                // Step 6.70: Return the Result object, with sample data

                /* use the following value for the Image:
                 *  full ="//www.loc.gov/pictures/cdn/service/pnp/cph/3c30000/3c34000/3c34900/3c34960_150px.jpg",
                 *  square = "//cdn.loc.gov/service/pnp/cph/3c30000/3c34000/3c34900/3c34960_75x75px.jpg",
                 * use the following value for the Links:
                 *  item = "//www.loc.gov/pictures/item/2004675446/",
                 *  resource ="//www.loc.gov/pictures/item/2004675446/resource/"
                 */
                new Result()
                {
                    title     = "SAMPLE: Michigan, Detroit, Campus Martius",
                    createdOn = "[between 1920 and 1940]",
                    // Step 6.80: Return the Image object, with sample data
                    image = new Image()
                    {
                        full   = "//www.loc.gov/pictures/cdn/service/pnp/cph/3c20000/3c23000/3c23000/3c23096_150px.jpg",
                        square = "https://dummyimage.com/75x75/cccccc/000000.jpg&text=gsdfgdfsdf+dsaf+"
                    },
                    // Step 6.90: Return the Links object, with sample data
                    links = new Links()
                    {
                        item     = "//www.loc.gov/pictures/item/99403554/",
                        resource = "//www.loc.gov/pictures/item/99403554/resource/"
                    }
                },
                // Step 6.100: Create a second Result object.
                new Result()
                {
                    title     = "SAMPLE: [Shubert's Detroit Opera House, Campus Martins, Detroit, Michigan]",
                    createdOn = "1929.",
                    image     = new Image()
                    {
                        full   = "//www.loc.gov/pictures/cdn/service/pnp/cph/3c30000/3c34000/3c34900/3c34960_150px.jpg",
                        square = "//cdn.loc.gov/service/pnp/cph/3c30000/3c34000/3c34900/3c34960_75x75px.jpg",
                    },
                    links = new Links()
                    {
                        item     = "//www.loc.gov/pictures/item/2004675446/",
                        resource = "//www.loc.gov/pictures/item/2004675446/resource/"
                    }
                }
            };
            return(data);
        }
コード例 #5
0
        // Step 9.60: Returns the LOCData, based on iterating the results from the Products object */
        private LOCData Get(string search)
        {
            // This will allow to get the base url.
            var request = HttpContext.Current.Request;
            var urlBase = "http://" + request.Url.Authority + "/WebPages";
            // Step 9.61: Create a products variable that gets data from the Products entity.  Convert it to a List
            //Student: Update your code here
            //var products = null;
            // Step 9.62: Create a filtered variable, using LINQ that filters if either search == null or the name contains search.
            //Student: Update your code here
            //var filtered = products.Where(x => true);
            // Step 9.63: Create a filteredFilled that filters out data with no images.  This can be determined by:
            // making sure the ProductProductPhotoes.ElementAt(0).ProductPhotoID value is not 1
            //Student: Update your code here
            //var filteredFilled = filtered.Where(x => true);

            var data    = new LOCData();
            var results = new List <Result>();

            // Step 9.64: Interate through all the filteredFilled items using the dbItems name.
            // foreach ...
            {
                // Step 9.65: For each item, create a Result object, call it item.
                //Student: Update your code here
                //var item = null;
                // Step 9.66: Populate the title with the dbItems' Name
                //Student: Update your code here
                //item.title = null;
                // Step 9.67: Populate the createdOn with the dbItems' ModifiedDate (need to convert it to a string)
                //Student: Update your code here
                //item.createdOn = null;
                // Step 9.68: The photo object can be gotten using dbItem.ProductProductPhotoes.First(), which grabs the first photo.
                //var productPhoto = null;
                // Step 9.69: Uncomment below.  This will initialise the image, and links object with image urls.
                // item.image = new Image()
                // {
                //     full = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=large",
                //     square = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=small"
                // };
                // item.links = new Links()
                // {
                //     item = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=small",
                //     resource = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=large"
                // };
                //results.Add(item);
            }
            // data.results = results;
            return(data);
        }
コード例 #6
0
        // Returns the LOCData, based on iterating the results from the Products object */
        // Step 9.60: Create a Get method, that given a search string, returns the LOCData object */
        private LOCData Get(string search)
        {
            // This will allow to get the base url.
            var request = HttpContext.Current.Request;
            var urlBase = "http://" + request.Url.Authority + "/WebPages";
            // Step 9.61: Create a products variable that gets data from the Products entity.  Convert it to a List

            var products = AdventureWorksDB.Products.AsEnumerable().ToList();
            // Step 9.62: Create a filtered variable, using LINQ that filters if either search == null or the name contains search.
            var filtered = products.Where(x => (search == null) || x.Name.Contains(search));
            // Step 9.63: Create a filteredFilled that filters out data with no images.  This can be determined by:
            // making sure the ProductProductPhotoes.ElementAt(0).ProductPhotoID value is not 1
            var filteredFilled = filtered.Where(x => x.ProductProductPhotoes.ElementAt(0).ProductPhotoID != 1);

            var data    = new LOCData();
            var results = new List <Result>();

            // Step 9.64: Interate through all the filteredFilled items using the dbItems name.
            foreach (var dbItem in filteredFilled)
            {
                // Step 9.65: For each item, create a Result object, call it item.
                var item = new Result();
                // Step 9.66: Populate the title with the dbItems' Name
                item.title = dbItem.Name;
                // Step 9.67: Populate the createdOn with the dbItems' ModifiedDate (need to convert it to a string)
                item.createdOn = dbItem.ModifiedDate.ToString();
                // Step 9.68: The photo object can be gotten using dbItem.ProductProductPhotoes.First(), which grabs the first photo.
                var productPhoto = dbItem.ProductProductPhotoes.First();
                // Step 9.69: Uncomment below.  This will initialise the image, and links object with image urls.
                item.image = new Image()
                {
                    full   = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=large",
                    square = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=small"
                };
                item.links = new Links()
                {
                    item     = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=small",
                    resource = urlBase + "/ProductImage.ashx?ProductID=" + productPhoto.ProductPhotoID + "&size=large"
                };
                results.Add(item);
            }
            data.results = results;
            return(data);
        }
コード例 #7
0
ファイル: LOCController .cs プロジェクト: brandlxee11/TobeIT
        public LOCData GetFromQueryString([FromUri] LOCRequest location)
        {
            var search = location.query;
            // Step 6.60: Return the LOCData object, with sample data
            var data = new LOCData();

            data.results = new List <Result>
            {
                // Step 6.70: Return the Result object, with sample data
                // use the following value for the Image:
                //       full ="//www.loc.gov/pictures/cdn/service/pnp/cph/3c30000/3c34000/3c34900/3c34960_150px.jpg",
                //       square = "//cdn.loc.gov/service/pnp/cph/3c30000/3c34000/3c34900/3c34960_75x75px.jpg",
                // use the following value for the Links:
                // item = "//www.loc.gov/pictures/item/2004675446/",
                // resource ="//www.loc.gov/pictures/item/2004675446/resource/"
                new Result()
                {
                    //Student: Insert your code here

                    // Step 6.80: Return the Image object, with sample data
                    image = new Image()
                    {
                        //Student: Insert your code here
                    },
                    // Step 6.90: Return the Links object, with sample data
                    links = new Links()
                    {
                        //Student: Insert your code here
                    }
                },
                // Step 6.100: Create a second Result object.
                new Result()
                {
                    //Student: Insert your code here
                }
            };
            return(data);
        }
コード例 #8
0
        // Step 8.60: Returns the LOCData, based on using LINQ
        private LOCData Get(string search)
        {
            // This will create a variable db that contains the entity information.
            using (var db = new ExperienceITDatabaseEntities())
            {
                // Step 8.61: Iterate the ResultsTables.
                var resultList = db.ResultsTables
                                 // Step 8.62: Filter based on the title containing the search value
                                 .Where(x => x.Title.Contains(search))
                                 // Step 8.63: transform the data from ResultsTable  to Result
                                 .Select <ResultsTable, Result>
                                     (t => new Result
                {
                    title     = t.Title,
                    createdOn = t.CreateDate,
                    image     = new Image()
                    {
                        full   = "https://dummyimage.com/275x275/aaaaaa/000000.jpg&text=" + t.Title,
                        square = "https://dummyimage.com/75x75/cccccc/000000.jpg&text=" + t.Title
                    },
                    links = new Links()
                    {
                        item     = "https://dummyimage.com/75x75/aaaaaa/000000.jpg&text=link:" + t.Title,
                        resource = "https://dummyimage.com/275x275/aaaaaa/000000.jpg&text=link:" + t.Title
                    }
                })
                                 .ToList(); // Converts to a list

                // This will return the resultList, and place it in an LOCData object.
                var data = new LOCData()
                {
                    results = resultList
                };
                return(data);
            }
        }