Skip to content

Commit

Permalink
Create alert div on insertUser with tuor fc not correct
Browse files Browse the repository at this point in the history
  • Loading branch information
Romans96 committed Oct 22, 2022
1 parent fe091a5 commit 765fedf
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
13 changes: 8 additions & 5 deletions NationalLibrary/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ public IActionResult router()

public IActionResult addUser()
{
Console.WriteLine("test");
if (userFinal == null || userFinal.Type.ToLower() == "user")
return RedirectToAction("Error");
{
return RedirectToAction("Error");
}

return View();
}

Expand Down Expand Up @@ -396,7 +398,6 @@ public IActionResult insertUser(UserFinalView user)
{
try
{

if (string.IsNullOrEmpty(user.FCRelatedTO) && (DateTime.Now - user.BirthDate).TotalDays > 6570)
{
DataQueries.InsertUser(user.FiscalCode, "User", user.Name, user.Surname, user.MobilePhone, user.BirthDate, user.City, user.Street,
Expand All @@ -414,14 +415,16 @@ public IActionResult insertUser(UserFinalView user)
}
else
{
return RedirectToAction("addUser");
return RedirectToAction("addUser");
}
return RedirectToAction("dashboard", userFinal);
}
}
catch (Exception ex)
{
return Error();
ViewData["Message"] = "Il Tutore non esiste, devi prima crearlo";
return View("addUser");
//return Error();
}
}
//public static UserFinalView getUserByFiscalCode(string FiscalCode, LibraryContext ctx)
Expand Down
23 changes: 23 additions & 0 deletions NationalLibrary/Views/Home/addUser.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@
<input minlength="16" maxlength="16" placeholder="Codice Fiscale" asp-for="@Model.FCRelatedTO" type="text" name="FCRelatedTO">
</div>
</div>
@if (ViewData["Message"] != null)
{
<div id="popuptutordiv"
style="border: none;
display: none;
color: red;
font-size: 13px;">
@ViewData["Message"]
</div>
<br />
}
<div class="inputContainer">
<label for="name">Nome</label>
<div>
Expand Down Expand Up @@ -158,4 +169,16 @@
</div>
</div>
</main>

<script type="text/javascript">
window.onload = async () => {
var tutorpopup = document.getElementById("popuptutordiv");
if (tutorpopup.innerHTML != '') {
tutorpopup.style.display = 'block';
await setTimeout(() => {
tutorpopup.style.display = 'none';
}, 5000);
}
}
</script>
</body>

0 comments on commit 765fedf

Please sign in to comment.