public SolrIssuersModel(Issuers isusr) { this.IssuerId = isusr.IssuerId.ToString(); this.Image = isusr.Image; this.Name = isusr.Name; this.WebsiteUrl = isusr.WebsiteUrl; this.Email = isusr.Email; this.Description = isusr.Description; this.UserId = isusr.UserId.ToString(); this.Staffsobject = isusr.Staffsobject; this.StaffsIds = isusr.StaffsIds; this.CreatedDate = isusr.CreatedDate; }
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")); }