-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
773 additions
and
610 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System.Diagnostics; | ||
using System.Security.Cryptography; | ||
using System.Text.Json; | ||
using AspnetCoreMvcFull.Context; | ||
using AspnetCoreMvcFull.Entities; | ||
using Microsoft.AspNetCore.Mvc; | ||
using AspnetCoreMvcFull.Models; | ||
using AspnetCoreMvcFull.Models.DTO; | ||
|
||
namespace AspnetCoreMvcFull.Controllers; | ||
|
||
public class AuthController : Controller, MethodController | ||
{ | ||
private Tsakitsaky Tsakitsaky; | ||
public AuthController(Tsakitsaky prom13) | ||
{ | ||
this.Tsakitsaky = prom13; | ||
} | ||
|
||
public IActionResult ForgotPasswordBasic() => View(); | ||
|
||
[HttpGet] | ||
public IActionResult LoginBasic() | ||
{ | ||
return View(); | ||
} | ||
|
||
[HttpGet] | ||
public IActionResult RegisterBasic() | ||
{ | ||
return View(); | ||
} | ||
public IActionResult LoginBasic(LoginDto loginDto) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
try | ||
{ | ||
Utilisateur user = (Utilisateur) loginDto.mapDtoToEntity(); | ||
user = user.getChauffeur(prom13: this.Tsakitsaky); | ||
HttpContext.Session.SetString("user", value: JsonSerializer.Serialize(user)); | ||
return Redirect("Dashboards/Index"); | ||
} | ||
catch (Exception e) | ||
{ | ||
ModelState.AddModelError("Error", e.Message); | ||
} | ||
} | ||
return View(loginDto); | ||
} | ||
|
||
public IActionResult RegisterBasic(RegisterDto registerDto) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
var user = registerDto.mapDtoToEntity(); | ||
TempData["user"] = user; | ||
HttpContext.Session.SetString("user", JsonSerializer.Serialize(user)); | ||
return Redirect("Dashboards/Index"); | ||
} | ||
return View(registerDto); | ||
} | ||
|
||
public IActionResult Logout() | ||
{ | ||
HttpContext.Session.Clear(); | ||
return Redirect("/Auth/LoginBasic"); | ||
} | ||
|
||
public IActionResult Form(object o) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace AspnetCoreMvcFull.Controllers; | ||
|
||
public class CsvController: Controller, MethodController | ||
{ | ||
private readonly IWebHostEnvironment _hostEnvironment; | ||
public CsvController(IWebHostEnvironment hostingEnvironment) | ||
{ | ||
this._hostEnvironment = hostingEnvironment; | ||
} | ||
|
||
[HttpGet] | ||
public IActionResult Index() | ||
{ | ||
Console.WriteLine("ETP "); | ||
return View(); | ||
} | ||
[HttpPost | ||
] | ||
public IActionResult Index(CsvDto csvDto) | ||
{ | ||
if (ModelState.IsValid) | ||
{ | ||
csvDto.saveFile(_hostEnvironment.WebRootPath); | ||
} | ||
ViewBag.title = "Formulaire csv"; | ||
return View(csvDto); | ||
} | ||
|
||
public IActionResult Form(object o) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public IActionResult UploadFiles(List<IFormFile> files) | ||
{ | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
namespace AspnetCoreMvcFull.Controllers; | ||
|
||
public class CsvDto | ||
{ | ||
private IFormFile csv; | ||
private string targetTable; | ||
|
||
public IFormFile Csv | ||
{ | ||
get => csv; | ||
set => csv = value ?? throw new ArgumentNullException(nameof(value)); | ||
} | ||
|
||
public string TargetTable | ||
{ | ||
get => targetTable; | ||
set => targetTable = value ?? throw new ArgumentNullException(nameof(value)); | ||
} | ||
|
||
public void saveFile(string filePath) | ||
{ | ||
if (this.Csv != null && this.Csv.Length > 0 && this.Csv.FileName.Contains(".csv")) | ||
{ | ||
var path = Path.Combine(filePath, "uploads/documents/csv/", this.Csv.FileName); | ||
using (var stream = System.IO.File.Create(path)) | ||
{ | ||
this.Csv.CopyTo(stream); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.