public IActionResult Login(Users user)
        {
            HttpResponseMessage response = _service.PostResponse(ApiUrl + "/api/account/login", user);

            if (response.IsSuccessStatusCode == false)
            {
                ViewBag.CheckCreadentials = "<p style='color: red'>Please check username or password</p>";
                return(View("Login"));
            }
            else
            {
                string           stringData  = response.Content.ReadAsStringAsync().Result;
                PersonWithCookie CookiesData = JsonConvert.DeserializeObject <PersonWithCookie>(stringData);

                string CookieJson = JsonConvert.SerializeObject(CookiesData.Cookies);
                HttpContext.Session.SetString("CookieData", CookieJson);
                HttpContext.Session.SetString("IdCard", CookiesData.Person.EmployeeCode);
                HttpContext.Session.SetString("Name", MakeFirstCapital(CookiesData.Person.FirstName) + " " + MakeFirstCapital(CookiesData.Person.LastName));
                HttpContext.Session.SetString("EmailId", CookiesData.Person.EmailAddress);
                HttpContext.Session.SetString("ImagePath", "EmployeeData/" + CookiesData.Person.TenantId + CookiesData.Person.EmployeeCode + "/Image/" + CookiesData.Person.Image);
                string role = CookiesData.Cookies.Role;
                TempData["BirthdayAlert"] = "Today is Birthday of ";
                return(RedirectToAction(role + "Dashboard", "Dashboard"));
            }
        }
 public IActionResult Login(Users user)
 {
     if (!(string.IsNullOrEmpty(user.UserName) || string.IsNullOrEmpty(user.Password)))
     {
         string status = _repository.Users.ValidateUser(user);
         if (status == "success")
         {
             Users            newUser    = _repository.Users.FindByUserName(user.UserName);
             JwtSecurityToken token      = _repository.Users.GenerateToken(newUser.Id);
             string           tokenValue = new JwtSecurityTokenHandler().WriteToken(token);
             int         pid             = newUser.PersonId;
             string      role            = "";
             Person      person          = new Person();
             CookieModel CookiesData     = new CookieModel();
             if (tokenValue != null)
             {
                 person = _repository.Employee.FindByCondition(x => x.Id == pid);
                 role   = _repository.Employee.GetDesignationById(person.RoleId).Name;
                 string data = _repository.Employee.GetDesignationById(person.RoleId).Access;
                 CookiesData = new CookieModel()
                 {
                     TokenValue   = tokenValue,
                     PersonId     = pid.ToString(),
                     Access       = data,
                     TenantId     = person.TenantId.ToString(),
                     EmployeeCode = person.EmployeeCode,
                     Role         = role
                 };
             }
             PersonWithCookie pc = new PersonWithCookie()
             {
                 Person  = person,
                 Cookies = CookiesData
             };
             _repository.Employee.Dispose();
             return(Ok(pc));
         }
     }
     return(NotFound(""));
 }