public async Task <IActionResult> Login(SignInDto model)
        {
            if (ModelState.IsValid)
            {
                var client = new HttpClient();
                HttpRequestMessage message = new HttpRequestMessage();
                message.Method = HttpMethod.Post;
                var    json    = JsonSerializer.Serialize(model);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");
                string url     = "https://localhost:44388/Api/Login";
                message.Content    = content;
                message.RequestUri = new Uri(url);

                var response = await client.SendAsync(message);

                var responsebody = await response.Content.ReadAsStringAsync();

                if (responsebody == "Incorrect Credentials")
                {
                    ViewBag.Error = responsebody;
                    return(View());
                }
                var res = JsonSerializer.Deserialize <DashBoardDto>(responsebody, new JsonSerializerOptions {
                    PropertyNameCaseInsensitive = true
                });
                if (res.Role.Contains("Admin"))
                {
                    var client2 = new HttpClient();
                    HttpRequestMessage message2 = new HttpRequestMessage();
                    message2.Headers.Authorization = new AuthenticationHeaderValue("Bearer", res.Token);
                    message2.Method = HttpMethod.Get;
                    //var json2 = JsonSerializer.Serialize(model);
                    //var content2 = new StringContent(json, Encoding.UTF8, "application/json");
                    string url2 = "https://localhost:44388/Api/GetUsers";
                    message2.RequestUri = new Uri(url2);

                    var response2 = await client2.SendAsync(message2);

                    var responsebody2 = await response2.Content.ReadAsStringAsync();
                }
                return(RedirectToAction("Index", "Dashboard", res));
            }
            var details = new DashBoardDto();

            return(View("Dashboard", details));
        }
        public async Task <IActionResult> GetUsers(DashBoardDto model)
        {
            if (ModelState.IsValid)
            {
                var client = new HttpClient();
                HttpRequestMessage message = new HttpRequestMessage();
                message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", model.Token);
                message.Method = HttpMethod.Get;
                var    json    = JsonSerializer.Serialize(model);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");
                string url     = "https://localhost:44388/Api/GetUsers";
                message.Content    = content;
                message.RequestUri = new Uri(url);

                var response = await client.SendAsync(message);

                var responsebody = await response.Content.ReadAsStringAsync();
            }
            return(View());
        }
 public IActionResult Index(DashBoardDto model)
 {
     ViewBag.IsLoggedIn = model.Role.Contains("Admin");
     ViewBag.IsAdmin    = true;
     return(View(model));
 }