public ActionResult Login(IFormCollection colle)
        {
            //and passing de db context to be used there.

            var UserLogin = new UserRepository(_db);
            var User      = UserLogin.Login(colle["username"], colle["password"]);

            //sample step check to see if the user is an adm or not, be an adm unlock the whole menu
            if (User.Permition_Id > 0)
            {
                //passing values about the user to the session
                string data = $"{User.UserName}_" +
                              $"{User.User_Id}_" +
                              $"{User.Permition.Permition_Type}_";
                //setting the session name and value
                HttpContext.Session.SetString("Loged", data);

                /*instance of resumerepository where contains methods which one bring all informations
                 * about an specific user*/
                var resume = new ResumeRepository(_db);
                //sending resume informations to the view by viewdata
                ViewData["resume"] = resume.GetResume(HttpContext);
                //returning view

                return(View("~/Views/Home/Index.cshtml"));
            }
            else
            {
                TempData["erro"] = "fail";
                return(View("~/Views/User/Index.cshtml"));
            }
        }
Example #2
0
    public async Task GetResume()
    {
        // Arrange
        var repo = new ResumeRepository();

        // Act
        var result = await repo.GetResume();

        // Assert
        Assert.Equal("Derek", result.FirstName);
    }
 public IActionResult Index()
 {
     if (string.IsNullOrEmpty(HttpContext.Session.GetString("Loged")))
     {
         return(View("~/Views/User/Index.cshtml"));
     }
     else
     {
         /*instance of resumerepository where contains methods which one bring all informations
          * about an specific user*/
         var resume = new ResumeRepository(_db);
         //sending resume informations to the view by viewdata
         ViewData["resume"] = resume.GetResume(HttpContext);
         //returning view
         return(View());
     }
 }