public ActionResult HomeChuKs(DashBoardChuKs dtoChuKs) { return(View(dtoChuKs)); }
public ActionResult Index() { if (Session["Authent"] != null) { DashboardAdmin dtoAdmin = new DashboardAdmin(); DashBoardChuKs dtoChuKs = new DashBoardChuKs(); using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["Authent"].ToString()); //Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); Task task = Task.Run(async() => { HttpResponseMessage Res = await client.GetAsync($"/manager/dashboard/info"); if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var EmpResponse = Res.Content.ReadAsStringAsync().Result; JavaScriptSerializer serializer = new JavaScriptSerializer(); var jsonObject = serializer.Deserialize <dynamic>(EmpResponse)["data"]; int role = Convert.ToInt32(Session["role"]); if (role == 2 || role == 3 || role == 4 || role == 5) { dtoAdmin.total_user = jsonObject["total_user"]; dtoAdmin.total = Convert.ToDouble(jsonObject["total"]); dtoAdmin.total_month = Convert.ToDouble(jsonObject["total_month"]); dtoAdmin.total_apartment = jsonObject["total_apartment"]; dtoAdmin.total_booking = jsonObject["total_booking"]; dtoAdmin.total_booking_finish = jsonObject["total_booking_finish"]; } if (role == 1) { dtoChuKs.total_good_review = jsonObject["total_good_review"]; dtoChuKs.total_review = jsonObject["total_review"]; dtoChuKs.total_apartment_rented = jsonObject["total_apartment_rented"]; dtoChuKs.total = jsonObject["total"]; dtoChuKs.total_month = jsonObject["total_month"]; dtoChuKs.total_apartment = jsonObject["total_apartment"]; dtoChuKs.total_booking = jsonObject["total_booking"]; dtoChuKs.total_booking_finish = jsonObject["total_booking_finish"]; } } }); task.Wait(); if (Convert.ToInt32(Session["role"]) == 1) { return(View("HomeChuKs", dtoChuKs)); } else { return(View(dtoAdmin)); } } } return(RedirectToAction("Login", "Account")); }