Bulelani Botman
Bulelani Botman
Explore posts from servers
CC#
Created by Bulelani Botman on 3/19/2024 in #help
How Can I Pull 900K Records From My Database & Not Have The Page Slow Down When Rendering The Record
I have a project that is pulling 900K records from a database & displaying them to a view. Whenever I pull these records, I get a connection timeout error. I fixed that by pulling the top 50000 records, it works but then I have a problem that it takes time to fully display the page. I also have a problem that I'm displaying these records using DataTables & takes time to load the JavaScript. How can I fix this?
59 replies
CC#
Created by Bulelani Botman on 2/20/2024 in #help
Trying To Use The UserManager.IsInRoleAsync() Function In My Controller
I'm trying to retrieve different information based on a user who is login in but which what role? I am not getting anywhere, Visual Studio is saying I cannot convert from "System.Security.Claims.ClaimsPrincipal" to "Microsoft.AspNetCore.Identity.IdentityUser". Is there something I am missing?
namespace parentnchild.Controllers
{
public class InitialController : Controller
{
private readonly ApplicationDbContext _db;
private readonly UserManager<IdentityUser> _userManager;

public InitialController(ApplicationDbContext context, UserManager<IdentityUser> userManager)
{
_db = context;
_userManager = userManager;
}

/* GET METHOD */
/* This is the initial view in our flow of registering a property as a parent. It just displays the search input box without any other information on the page */
public IActionResult InitialView()
{

if (_userManager.IsInRoleAsync(User, "NORTH"))
{
List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("NORTH")).ToList();
return View(results);
}
else if (_userManager.IsInRoleAsync(User, "SOUTH"))
{

List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("SOUTH")).ToList();
return View(results);
}
else if (_userManager.IsInRoleAsync(User, "EAST"))
{

List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("EAST")).ToList();
return View(results);
}
else if (_userManager.IsInRoleAsync(User, "WEST"))
{

List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("WEST")).ToList();
return View(results);
}
else
{
List<LIS> results = _db.LIS.ToList();
return View(results);
}

}
}
namespace parentnchild.Controllers
{
public class InitialController : Controller
{
private readonly ApplicationDbContext _db;
private readonly UserManager<IdentityUser> _userManager;

public InitialController(ApplicationDbContext context, UserManager<IdentityUser> userManager)
{
_db = context;
_userManager = userManager;
}

/* GET METHOD */
/* This is the initial view in our flow of registering a property as a parent. It just displays the search input box without any other information on the page */
public IActionResult InitialView()
{

if (_userManager.IsInRoleAsync(User, "NORTH"))
{
List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("NORTH")).ToList();
return View(results);
}
else if (_userManager.IsInRoleAsync(User, "SOUTH"))
{

List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("SOUTH")).ToList();
return View(results);
}
else if (_userManager.IsInRoleAsync(User, "EAST"))
{

List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("EAST")).ToList();
return View(results);
}
else if (_userManager.IsInRoleAsync(User, "WEST"))
{

List<LIS> results = _db.LIS.Where(s => s.Sector.Contains("WEST")).ToList();
return View(results);
}
else
{
List<LIS> results = _db.LIS.ToList();
return View(results);
}

}
}
6 replies
CC#
Created by Bulelani Botman on 1/18/2024 in #help
I Keep On Getting An SQLException When Trying To Update My Database
I keep on getting an "SqlException: Cannot insert explicit value for identity column in table 'Loans' when IDENTITY_INSERT is set to OFF" even though I am not expliitlyl inserting a value on a identity column on the table. What I am using is using the ID from another table called Applicants & updating a column in Loans called ApplicantID with the ID from this table, I don't get this error. I am using ASP.NET Core MVC, I just got an internship & the company uses this framework & I've been trying to learn it on my own because this is the first time ever in my life touching C#. Please upgrade the appsettings.json to your configuration if you intend to download the solution and figure out what is wrong. I am also willing to explain every question about a function or class because I didn't document the code. Also I didn't push the migrations to the github page. https://github.com/inalelub/homeloan
33 replies
KPCKevin Powell - Community
Created by Bulelani Botman on 12/27/2023 in #front-end
A Problem With Setting The <main> Content To Full Viewport!
I have a page where I was having problems with setting the navbar at the top of the viewport. I was able to fix it with setting the border-top to some 20px whenever you load the site so that the <main> content doesn't overlap with the navbar. Now in the navbar I have two links which link to the 2 sections in the <main>! Whenever I click one link the <main> overlaps the navbar which is something I don't want. I want whenver you click the link the <section> / <main> stays below the navbar as intended and doesn't overlap the navbar content. I have a link to the codepen to see the full code. Try loading the website in the browser & notice how <main> content is below the navbar as intended but whenever you click the "work" link in the navbar the content of the <main> it overlaps. [https://codepen.io/inalelub/pen/QWobwRW]
3 replies
KPCKevin Powell - Community
Created by Bulelani Botman on 9/25/2023 in #front-end
Having Issues With The Height Property
I wanted to know if it is appropriate declaring your height on the html element for a fresh html project, so you can work on that. I ran into an issue trying to learn how to build header's & footer's, so I wanted my footer to be at the bottom of the page while my header stays at the top & my main element have some height that fills the whole screen without it having to scroll to reach the bottom. In my codepen, if you comment out the height for the main, the footer & header collapse and become one block but I wanted them to stick to the top & bottom so I declared the height for the main element where content would sit. Here is the link to the Codepen
2 replies