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);
}
}
}