public async Task <ActionResult> InitMedia()
        {
            string json;

            using (var fs = new FileStream(this.Server.MapPath("~/Content/Startup/searchSeed.json"), FileMode.Open))
            {
                using (var sr = new StreamReader(fs))
                {
                    json = sr.ReadToEnd();
                }
            }

            var attribute =
                typeof(MediaItem).GetCustomAttributes(typeof(DocumentAttribute), true).FirstOrDefault() as
                DocumentAttribute;

            if (attribute == null)
            {
                throw new ArgumentException("Model does not implement custom attribute 'Document'");
            }

            var collectionId = attribute.CollectionId;
            var databaseId   = attribute.DatabaseId;

            await SearchDbInitializer <SearchableMediaItem> .Initialize(json, "media");

            return(this.View("InitStatus", true));
        }
Beispiel #2
0
        public async Task <ActionResult> InitSearchDb()
        {
            string json;

            using (var fs = new FileStream(this.Server.MapPath("~/Content/Startup/searchSeed.json"), FileMode.Open))
            {
                using (var sr = new StreamReader(fs))
                {
                    json = sr.ReadToEnd();
                }
            }

            await SearchDbInitializer <SearchableMediaItem> .Initialize(json, "media");

            return(this.View("InitSearchDb"));
        }