public void DeleteIndex()
        {
            Log.Info("Deletes intire index for reindexing");
            SolrQuery sq = new SolrQuery("*:*");

            _solr.Delete(sq);
            _solr.Commit();
        }
Exemplo n.º 2
0
        public ActionResult RemoveAll()
        {
            var message = string.Empty;

            solr.Delete(SolrQuery.All);
            solr.Commit();

            return(Json(new { message }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public void Add_then_query()
        {
            const string name = "Samsuñg SpinPoint P120 SP2514N - hárd drívè - 250 GB - ÁTÀ-133";
            var          guid = new Guid("{78D734ED-12F8-44E0-8AA3-8CA3F353998D}");
            var          p    = new Product {
                Id   = "SP2514N",
                Guid = guid,
                Name = name,
                // testing UTF
                Manufacturer = "Samsung Electronics Co. Ltd.",
                Categories   = new[] {
                    "electronics",
                    "hard drive",
                },
                Features = new[] {
                    "7200RPM, 8MB cache, IDE Ultra ATA-133",
                    "NoiseGuard, SilentSeek technology, Fluid Dynamic Bearing (FDB) motor",
                    "áéíóúñç & two",                                                               // testing UTF
                    @"ÚóÁ⌠╒""ĥÛē…<>ܐóジャストシステムは、日本で初めてユニコードベースのワードプロセ ッサーを開発しました。このことにより、10年以上も前から、日本のコンピューターユーザーはユニコード、特に日中韓の統合漢 字の恩恵を享受してきました。ジャストシステムは現在、”xfy”というJava環境で稼働する 先進的なXML関連製品の世界市場への展開を積極的に推進していますが、ユニコードを基盤としているために、”xfy”は初めから国際化されているのです。ジャストシステムは、ユニコードの普遍的な思想とアーキテクチャに 感謝するとともに、その第5版の刊行を心から歓迎します",
                    @"control" + (char)0x07 + (char)0x01 + (char)0x0E + (char)0x1F + (char)0xFFFE, // testing control chars
                },
                Prices = new Dictionary <string, decimal> {
                    { "regular", 150m },
                    { "afterrebate", 100m },
                },
                Price         = 92,
                PriceMoney    = new Money(92m, "USD"),
                Popularity    = 6,
                InStock       = true,
                DynCategories = new Dictionary <string, ICollection <string> > {
                    { "t", new[] { "something" } },
                }
            };

            solr.Delete(SolrQuery.All);
            solr.AddWithBoost(p, 2.2);
            solr.Commit();

            solr.Query(new SolrQueryByField("name", @"3;Furniture"));
            var products = solr.Query(new SolrQueryByRange <decimal>("price", 10m, 100m).Boost(2));

            Assert.AreEqual(1, products.Count);
            Assert.AreEqual(name, products[0].Name);
            Assert.AreEqual("SP2514N", products[0].Id);
            Assert.AreEqual(guid, products[0].Guid);
            Assert.AreEqual(92m, products[0].Price);
            Assert.IsNotNull(products[0].Prices);
            Assert.AreEqual(2, products[0].Prices.Count);
            Assert.AreEqual(150m, products[0].Prices["regular"]);
            Assert.AreEqual(100m, products[0].Prices["afterrebate"]);
            Assert.IsNotNull(products.Header);
        }
Exemplo n.º 4
0
 public IActionResult Update(int id, Posts model, string Solr)
 {
     if (ModelState.IsValid)
     {
         var b = _db.Posts.Where(b => b.PostID == id).FirstOrDefault();
         b.PostContent  = model.PostContent;
         b.PostExcerpt  = model.PostExcerpt;
         b.PostTitle    = model.PostTitle;
         b.PostAuthor   = model.PostAuthor;
         b.PostLocation = model.PostLocation;
         b.CategoryID   = model.CategoryID;
         _db.Update(b);
         _db.SaveChanges();
         if (Solr == "Yes")
         {
             var s = new PersonalWebsiteMVC.Models.SolrModel();
             s.ID    = model.PostID.ToString();
             s.Title = model.PostTitle;
             s.Url   = "http://www.douglasmcgregor.co.uk/Blog?q=" + model.PostID;
             s.Body  = model.PostContent;
             _solr.Add(s);
             _solr.Commit();
         }
         if (Solr == "No")
         {
             SolrQueryByField results = new SolrQueryByField("ID", model.PostID.ToString());
             _solr.Delete(results.FieldValue);
             _solr.Commit();
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Exemplo n.º 5
0
        public void DeleteFromPublishedIndex(object id)
        {
            ISolrOperations <CmsSearchResultItemPublished> instancePublished = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItemPublished> >();

            instancePublished.Delete(id.ToString());
            instancePublished.Commit();
        }
Exemplo n.º 6
0
        public void DeleteMediaFromIndex(string mediaId)
        {
            ISolrOperations <CmsSearchResultItem> instance = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItem> >();

            instance.Delete(mediaId.StartsWith("media") ? mediaId.ToString((IFormatProvider)CultureInfo.InvariantCulture) : "media" + mediaId.ToString((IFormatProvider)CultureInfo.InvariantCulture));
            instance.Commit();
        }
        void Provider_OnUpdateItem(object sender, EventArgs e)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(e, "e");
            Database database = SitecoreEventArgs.GetObject(e, 0) as Database;

            if ((database != null) && (database.Name == this.m_database.Name))
            {
                ID iD = SitecoreEventArgs.GetID(e, 1);
                Assert.IsNotNull(iD, "ID is not passed to RemoveItem handler");
                solr.Delete(IdHelper.NormalizeGuid(iD.ToString(), false));
                // solr.Add(new SOLRItem());
                solr.Commit();
                solr.Optimize();
            }
        }
Exemplo n.º 8
0
        public IActionResult BadgeDelete(string id)
        {
            ObjectId oId = new ObjectId(id);

            var   earnerBadge = earnerBadgeDetails.DeleteMany <EarnerBadgeDetails>(e => e.BadgeId == oId);
            Badge badg        = badgeCollection.Find(e => e.BadgeId
                                                     == oId).FirstOrDefault();

            SolrBadgeModel sbdg = new SolrBadgeModel(badg);

            _solr.Delete(sbdg);
            _solr.Commit();
            var badge = badgeCollection.DeleteOne <Badge>(e => e.BadgeId == oId);         //To delete


            if (badge.IsAcknowledged)
            {
                TempData["Message"] = "Employee deleted successfully!";
            }
            else
            {
                TempData["Message"] = "Error while deleting Employee!";
            }
            return(RedirectToAction("Issuers"));
        }
Exemplo n.º 9
0
        public IActionResult Delete(string id)
        {
            ObjectId userId     = new ObjectId(id);
            var      userRoleId = usersCollection.Find(e => e.UserId == userId).FirstOrDefault().RoleId;
            var      userRole   = userRoleCollection.Find(e => e.RoleId == new ObjectId(userRoleId)).FirstOrDefault().Role;

            if (userRole == AppUtility.IssuerRole)
            {
                issuersCollection.DeleteOne <Issuers>(item => item.UserId == userId);
            }
            Users user   = usersCollection.Find(e => e.UserId == userId).FirstOrDefault();
            var   delete = usersCollection.DeleteOne <Users>(e => e.UserId == userId);

            if (delete.DeletedCount > 0)
            {
                SolrUsersModel solUserMod = new SolrUsersModel(user);
                var            results    = _solr.Delete(solUserMod);
                //Saving the changes
                _solr.Commit();
            }

            if (delete.IsAcknowledged)
            {
                TempData["Message"] = "Role deleted successfully!";
            }
            else
            {
                TempData["Message"] = "Error while deleting Rolee!";
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
        private static void DeleteIndex <T>(ISolrOperations <T> solr)
        {
            Console.WriteLine("Clearing Index");
            var solrQueryResults = solr.Query(new SolrQuery("*"));

            solr.Delete(solrQueryResults);
            solr.Commit();
        }
Exemplo n.º 11
0
        /// <summary>
        /// removes a given user's repo from a channel
        /// </summary>
        /// <param name="user"></param>
        /// <param name="channel"></param>
        /// <param name="repository"></param>
        public void UntrackRepository(GitHubUser user, String repository)
        {
            ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >();

            solr.Delete(new SolrQuery("channel:" + user.ChannelID) && new SolrQuery("repo:" + repository) && new SolrQuery("committer_name:" + user.UserID));

            solr.Commit();
        }
Exemplo n.º 12
0
 public void DeleteIndex()
 {
     try
     {
         Log.Info("Deletes intire index for reindexing");
         SolrQuery sq = new SolrQuery("*:*");
         _solr.Delete(sq);
         _solr.Commit();
     }
     catch (SolrNet.Exceptions.SolrConnectionException)
     {
         Log.Error("Connection to solr failed");
     }
     catch (Exception ex)
     {
         Log.Error("Error:" + ex.Message);
     }
 }
Exemplo n.º 13
0
 public virtual void Delete(TId id)
 {
     if (Equals(id, default(TId)))
     {
         return;
     }
     _solrOperations.Delete(id.ToString());
     _solrOperations.Commit();
 }
Exemplo n.º 14
0
        public int Del(List <int> ids)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("DELETE FROM dbo.sys_organize WHERE id IN @ids");
            using (LocalDB db = new LocalDB())
            {
                int cnt = db.Current_Conn.Execute(sql.ToString(), new { ids = ids });
                List <ISolrQuery> qs = new List <ISolrQuery>();
                foreach (int id in ids)
                {
                    qs.Add(new SolrQuery("entitytype:sys_organize && id:" + id.ToString()));
                }
                solr.Delete(new SolrMultipleCriteriaQuery(qs, "OR"));
                solr.Commit();
                return(cnt);
            }
        }
Exemplo n.º 15
0
 public int Del(List <int> ids)
 {
     using (LocalDB db = new LocalDB())
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("select * from sys_role where id in @ids");
         int cnt = db.Current_Conn.Execute(sql.ToString(), new { ids = ids });
         if (cnt > 0)
         {
             List <ISolrQuery> qs = new List <ISolrQuery>();
             foreach (var id in ids)
             {
                 qs.Add(new SolrQuery("entitytype:sys_role && id:" + id.ToString()));
             }
             solr.Delete(new SolrMultipleCriteriaQuery(qs, "OR"));
             solr.Commit();
         }
         return(cnt);
     }
 }
Exemplo n.º 16
0
        private int DeleteSubFingerprintsForTrack(IModelReference trackReference)
        {
            string trackId = SolrModelReference.GetId(trackReference);
            string readAll = string.Format("trackId:{0}", trackId);
            var    results = solrForSubfingerprintsCore.Query(new SolrQuery(readAll));
            var    ids     = results.Select(dto => dto.SubFingerprintId).ToList();

            solrForSubfingerprintsCore.Delete(ids);
            solrForSubfingerprintsCore.Commit();
            return(ids.Count);
        }
Exemplo n.º 17
0
        public int Del(int id)
        {
            using (LocalDB db = new LocalDB())
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("WITH cte_name \n");
                sql.Append("     AS (SELECT id, \n");
                sql.Append("                pid, \n");
                sql.Append("                title \n");
                sql.Append("         FROM   dbo.sys_menu \n");
                sql.Append("         WHERE  id = @id \n");
                sql.Append("         UNION ALL \n");
                sql.Append("         SELECT ta.id, \n");
                sql.Append("                ta.pid, \n");
                sql.Append("                ta.title \n");
                sql.Append("         FROM   dbo.sys_menu ta \n");
                sql.Append("                JOIN cte_name tb \n");
                sql.Append("                  ON ta.pid = tb.id) \n");
                sql.Append("SELECT id \n");
                sql.Append("FROM   cte_name");

                IEnumerable <int> delids = db.Current_Conn.Query <int>(sql.ToString(), new { id = id });
                StringBuilder     sql1   = new StringBuilder();
                sql1.Append("begin tran \n");
                sql1.Append("delete from sys_menu where id in @ids\n");
                sql1.Append("delete from sys_role_menu where menu_id in @ids\n");
                sql1.Append("commit \n");
                int cnt = db.Current_Conn.Execute(sql1.ToString(), new { ids = delids });
                if (cnt > 0)
                {
                    List <ISolrQuery> qs = new List <ISolrQuery>();
                    foreach (var delid in delids)
                    {
                        qs.Add(new SolrQuery("entitytype:sys_menu") && new SolrQuery("id: " + delid.ToString()));
                    }
                    solr.Delete(new SolrMultipleCriteriaQuery(qs, "OR"));
                    solr.Commit();
                }
                return(cnt);
            }
        }
Exemplo n.º 18
0
        public void ClearIndex()
        {
            ISolrOperations <CmsSearchResultItem>          instance          = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItem> >();
            ISolrOperations <CmsSearchResultItemPublished> instancePublished = ServiceLocator.Current.GetInstance <ISolrOperations <CmsSearchResultItemPublished> >();

            this.log.AddLogentry(SolisSearch.Log.Enum.LogLevel.Info, "Clearing index", (Exception)null);

            instance.Delete((ISolrQuery) new SolrQuery("id:[* TO *]"));
            instance.Commit();

            instancePublished.Delete((ISolrQuery) new SolrQuery("id:[* TO *]"));
            instancePublished.Commit();
        }
Exemplo n.º 19
0
        public IActionResult Delete()
        {
            var options = new QueryOptions();

            options.ExtraParams = new KeyValuePair <string, string>[] {
                //new KeyValuePair<string, string>("wt", "xml");
            };
            string           id      = HttpContext.Request.Query["q"];
            SolrQueryByField results = new SolrQueryByField("ID", id);

            solr.Delete(results.FieldValue);
            solr.Commit();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 20
0
        public ActionResponse Execute()
        {
            _context.Warn("Initializing");

            List <CoreResult> cores = null;

            try {
                cores = _admin.Status();
            } catch (Exception ex) {
                return(new ActionResponse()
                {
                    Code = 500, Message = $"Count not access {_context.Connection.Url}: {ex.Message}"
                });
            }

            var coreFolder = new DirectoryInfo(Path.Combine(_context.Connection.Folder, _context.Connection.Core));

            if (!coreFolder.Exists)
            {
                coreFolder.Create();
                // https://stackoverflow.com/questions/58744/copy-the-entire-contents-of-a-directory-in-c-sharp
                var sourceFolder = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "files\\solr"));
                foreach (string d in Directory.GetDirectories(sourceFolder.FullName, "*", SearchOption.AllDirectories))
                {
                    Directory.CreateDirectory(d.Replace(sourceFolder.FullName, coreFolder.FullName));
                }
                foreach (string f in Directory.GetFiles(sourceFolder.FullName, "*.*", SearchOption.AllDirectories))
                {
                    File.Copy(f, f.Replace(sourceFolder.FullName, coreFolder.FullName), true);
                }
            }

            File.WriteAllText(Path.Combine(Path.Combine(coreFolder.FullName, "conf"), "schema.xml"), _engine.Render());

            if (cores.Any(c => c.Name == _context.Connection.Core))
            {
                _admin.Reload(_context.Connection.Core);
            }
            else
            {
                _admin.Create(_context.Connection.Core, _context.Connection.Core);
            }

            _solr.Delete(SolrQuery.All);
            _solr.Commit();

            return(new ActionResponse());
        }
Exemplo n.º 21
0
        public static bool delete(Guid applicationId, List <SearchDoc> documents)
        {
            try
            {
                ISolrOperations <SolrDoc> solr = get_solr_operator();
                documents.ForEach(d => solr.Delete(d.toSolrDoc(applicationId)));
                ResponseHeader response = solr.Commit();

                return(response.Status == 0);
            }
            catch (Exception ex)
            {
                LogController.save_error_log(null, null, "SolrRemoveDocument", ex, ModuleIdentifier.SRCH);
                return(false);
            }
        }
Exemplo n.º 22
0
        public void Setup()
        {
            solr = ServiceLocator.Current.GetInstance <ISolrOperations <Product> >();
            solr.Delete(SolrQuery.All);
            solr.Commit();

            var connection = ServiceLocator.Current.GetInstance <ISolrConnection>();
            var files      = Directory.GetFiles(DirectoryUtility.GetDirectoryXmlFile(), "*.xml");

            foreach (var file in files)
            {
                connection.Post("/update", File.ReadAllText(file, Encoding.UTF8));
            }

            solr.Commit();
        }
        public bool DeleteData(ISolrOperations <SearchResultItem> solr, string id)
        {
            bool result;

            try
            {
                solr.Delete(id);
                solr.Commit();
                result = true;
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Untracks the provided repository from a channel and deletes its documents from Solr.
 /// </summary>
 public void UntrackRepository(GitHubUser user, List <String> repositories)
 {
     try
     {
         ISolrOperations <CodeDoc> solr = ServiceLocator.Current.GetInstance <ISolrOperations <CodeDoc> >();
         foreach (string repo in repositories)
         {
             solr.Delete(new SolrQuery("channel:" + user.ChannelID) && new SolrQuery("repo:" + repo) && new SolrQuery("committer_name:" + user.UserID));
         }
         solr.Commit();
     }
     catch (Exception ex)
     {
         Console.WriteLine(String.Format("Error attemtping to untrack repositories for user {0}", user.UUID));
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 25
0
        // Delete a singe document matched by the query
        public string DeleteDoc(string q)
        {
            string res = "Didnt run..";

            try
            {
                SolrQuery query = new SolrQuery(q);

                res = solr.Delete(query).Status.ToString();
                Commit();
            }
            catch (Exception e)
            {
                solr.Rollback();
                res = e.ToString();
            }
            return(res);
        }
Exemplo n.º 26
0
 public virtual void OnPostDelete(PostDeleteEvent e)
 {
     if (e.Entity.GetType() != typeof(T))
     {
         return;
     }
     if (DeferAction(e.Session))
     {
         Delete(e.Session.Transaction, (T)e.Entity);
     }
     else
     {
         solr.Delete((T)e.Entity);
         if (Commit)
         {
             solr.Commit();
         }
     }
 }
Exemplo n.º 27
0
        public static void ReIndexAllCourses()
        {
            //initialize the connection
            Startup.Init <Course>("http://desktop-nphjedv:8983/solr/courses");

            ISolrOperations <Course> solr = ServiceLocator.Current.GetInstance <ISolrOperations <Course> >();

            //delete all documents
            solr.Delete(SolrQuery.All);

            //load json file
            var courses = JsonConvert.DeserializeObject <List <Course> >(File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "courses.json")));

            //update the index
            foreach (var course in courses)
            {
                solr.Add(course);
            }
            solr.Commit();
        }
Exemplo n.º 28
0
 private void TearDownDocs(ISolrOperations <SubFingerprintDTO> solr, IEnumerable <SubFingerprintDTO> subFingerprintDtos)
 {
     solr.Delete(subFingerprintDtos.Select(dto => dto.SubFingerprintId));
     solr.Commit();
 }
Exemplo n.º 29
0
        private void UpdateSolrIndexForProject(IndexSettings settings, ISolrOperations<CodeDocument> solr, Project proj)
        {
            List<string> alldocs = null;

            //find out if directory exists before doing anything to the index
            if (!Directory.Exists(proj.Path))
            {
                Console.WriteLine(DateTime.Now.ToString() + ": Directory for project " + proj.ProjectName + " did not exist, skipping");
                return;
            }

            //find all of the files
            using (var csw = new ConsoleStopWatch(""))
            {

                alldocs = GetDocsForProject(proj, settings.DefaultIncludedPath, settings.DefaultExcludedPath);
                csw.Name = "Finding " + alldocs.Count.ToString() + " files for project " + proj.ProjectName;
            }

            using (var csw = new ConsoleStopWatch("Deleting all solr docs for project " + proj.ProjectName))
            {
                solr.Delete(new SolrQuery("project:\"" + proj.ProjectName + "\""));
                solr.Commit();
            }

            //breakout the file list into chunks of DOCS_PER_POST for speed. One at a time is too slow, too many can cause solr memory and thread issues
            var fileChunks = Chunkify(alldocs.ToArray(), DOCS_PER_POST);

            using (var csw = new ConsoleStopWatch("Adding the documents to solr for project " + proj.ProjectName))
            {
                //convert each to a solr document
                for (int i = 0; i < fileChunks.Length; i++)
                {
                    var file = fileChunks[i];
                    var codedocs = MakeDocument(file, proj);
                    //submit each to solr
                    //Tweak to leverage new CommitIWithin option of SolrNet so that we do not need to pay the cost of a commit for each group.
                    solr.AddRange(codedocs, new AddParameters { CommitWithin = 10000 });

                }

                solr.Optimize();

            }
        }
Exemplo n.º 30
0
        static void Main(string[] args)
        {
            //Change alpharetta to either localhost or your machine name
            Startup.Init <Course>("http://localhost:8983/solr/courses");

            ISolrOperations <Course> solr = ServiceLocator.Current.GetInstance <ISolrOperations <Course> >();

            //Show Solr Admin UI and then delete all
            solr.Delete(SolrQuery.All); //Equivalent to "*:*"

            //Don't forget to commit
            solr.Commit();

            //Add one document
            //Note: create and udpate are the same
            Course courseSolr = new Course();

            courseSolr.CourseId    = "enterprise-search-using-apache-solr";
            courseSolr.CourseTitle = "Getting Started with JSON in C# Using Json.NET";
            courseSolr.Author      = new List <string>();
            courseSolr.Author.Add("Xavier Morera");
            courseSolr.Tags = new List <string>();
            courseSolr.Tags.Add("solr");
            courseSolr.Tags.Add("big-data");
            courseSolr.Description = "Search is one of the most misunderstood functionalities in the IT industry. Even further, Enterprise Search used to be neither for the faint of heart, nor for those with a thin wallet. However, since the introduction of Apache Solr, the name of the game has changed. Apache Solr brings high quality Enterprise Search to the masses. Don?t leave home without it!";

            solr.Add(courseSolr);

            solr.Commit();

            //Add a couple of documents in a single command
            List <Course> courses = new List <Course>();

            Course courseGit = new Course();

            courseGit.CourseId    = "using-git-with-gui";
            courseGit.CourseTitle = "Getting Started with JSON in C# Using Json.NET";
            courseGit.Author      = new List <string>();
            courseGit.Author.Add("Xavier Morera");
            courseGit.Tags = new List <string>();
            courseGit.Tags.Add("json");
            courseGit.Tags.Add("microsoft");
            courseGit.Tags.Add("javascript");
            courseGit.Description = "There is no doubt Git is taking over the world of source control management, mainly in open source but growing rapidly in enterprise as well. The problem usually lies in that Git is not for the faint of heart as it comes with a steep learning curve - it is hard to get started. In this course, I will help you smooth out the learning curve, understand Git?s mechanics and branching model, and in general be productive much quicker with the aid of a great free tool: Atlassian SourceTree.";

            courses.Add(courseGit);

            Course courseJson = new Course();

            courseJson.CourseId    = "json-csharp-jsondotnet-getting-started";
            courseJson.CourseTitle = "Using Git with a GUI";
            courseJson.Author      = new List <string>();
            courseJson.Author.Add("Xavier Morera");
            courseJson.Tags = new List <string>();
            courseJson.Tags.Add("git");
            courseJson.Tags.Add("source-control");
            courseJson.Description = "The rising popularity of the web, mainly around JavaScript related technologies, has given JSON a great deal of importance over other data interchange formats, like XML. JSON is a lightweight, human-readable, efficient, and easy to understand data interchange format. JSON stands for JavaScript Object Notation. If you are a C# or .NET developer who needs to work with JSON, or even understand what JSON is, then this course is for you. In this course, we will learn how to serialize, deserialize, use LINQ To JSON, improve serialization performance, BSON, create schemas, validate JSON, and, in general, work with Json.NET, a popular, high performance, free, and open source JSON framework for .NET.";

            courses.Add(courseJson);

            solr.AddRange(courses);
            solr.Commit();
        }
Exemplo n.º 31
0
        public IActionResult IssuersDelete(string id)
        {
            ObjectId oId    = new ObjectId(id);
            var      issuer = _i.FindById(id);

            var users        = _user.AsQueryable().ToList();
            var userToDelete = users.Where(e => e.Id == issuer.UserId).FirstOrDefault();

            DigiBadges.Models.Users usrMod = new DigiBadges.Models.Users()
            {
                CreatedBy      = userToDelete.CreatedBy,
                CreatedDate    = userToDelete.CreatedDate,
                Email          = userToDelete.Email,
                FirstName      = userToDelete.FirstName,
                IsUserVerified = userToDelete.IsUserVerified,
                Password       = userToDelete.Password,
                RoleId         = userToDelete.RoleId,
                UserId         = userToDelete.Id
            };

            DigiBadges.Models.Issuers issMod = new DigiBadges.Models.Issuers()
            {
                IssuerId    = issuer.Id,
                Image       = issuer.Image,
                Name        = issuer.Name,
                WebsiteUrl  = issuer.WebsiteUrl,
                Email       = issuer.Email,
                Description = issuer.Description,
                UserId      = issuer.UserId,
                StaffsIds   = issuer.StaffsIds,
                CreatedDate = issuer.CreatedDate
            };

            SolrUsersModel   solUserMod = new SolrUsersModel(usrMod);
            SolrIssuersModel sissuser   = new SolrIssuersModel(issMod);



            _user.DeleteById(userToDelete.Id.ToString());                        //Deleting user from user collection
            var result = collection.DeleteOne <Issuers>(e => e.IssuerId == oId); //Deleting user from issuer collection

            if (result.DeletedCount > 0)
            {
                var results = _solr.Delete(solUserMod);
                //Saving the changes
                _solr.Commit();



                _solrIssuer.Delete(sissuser);
                _solrIssuer.Commit();
            }

            var badges = _b.FilterBy(e => e.IssuerId == issuer.Id).ToList();

            if (badges != null)
            {
                _b.DeleteMany(e => e.IssuerId == issuer.Id);
            }

            return(RedirectToAction("Index"));
        }