public IActionResult DashBoard(DashBoardViewModel model, string filterValues, bool deleteFilter, int pageIndex = 1, int pageSize = 10) { if (!string.IsNullOrEmpty(model.IdCampaign)) { SetSessionVariable("idCampaign", model.IdCampaign); } else if (!string.IsNullOrEmpty(filterValues) || pageIndex != 1) { model.IdCampaign = GetSessionVariable("idCampaign"); } ViewBag.CampaignList = _campaignBusiness.GetActiveCampaignsList(ApplicationUserCurrent.AccountId) .Select(c => new SelectListItem() { Value = _protectorCampaign.Protect(c.Id.ToString()), Text = c.Name }); var filters = GetFilters(filterValues, deleteFilter); model = _homeBusiness.GetDashBoard(model, filters, pageIndex, pageSize, ApplicationUserCurrent.AccountId, _protectorCampaign); if (!string.IsNullOrEmpty(model.IdCampaign)) { model.IdCampaign = _protectorCampaign.Protect(model.IdCampaign); } return(View(model)); }
public IActionResult DashBoard(DashBoardViewModel model, string filterValues, bool deleteFilter, int pageIndex = 1, int pageSize = 50) { using (var clientw = new HttpClient()) { clientw.BaseAddress = new Uri("http://geomardis6728.cloudapp.net:8000/api/3.0/"); var json = JsonConvert.SerializeObject("<tsRequest >\r\n < credentials name =\"administrador\" password=\"M@rdisserver2018\" >\r\n <site contentUrl=\"\" />\r\n </credentials>\r\n</tsRequest>", Formatting.Indented); var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); var buffer = System.Text.Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var responseTask = clientw.PostAsync("auth/signin", byteContent); responseTask.Wait(); } // var result = responseTask.Result; // var requestUrl = "http://geomardis6728.cloudapp.net:8000/api/3.0/auth/signin"; // string jsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(json); // HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUrl); // requestMessage.Content = new StringContent(jsonBody); // var requestBody = requestMessage.Content.ReadAsStringAsync().Result; // Add body content // requestMessage.Content = new StringContent( // jsonBody.ToString(), // Encoding.UTF8, // "application/json" // ); // var result = client.SendAsync(requestMessage); // result.Wait(); // var re = result.Result; // //if (result.IsSuccessStatusCode) // //{ // // var readTask = result.Content.ReadAsAsync<IList<StudentViewModel>>(); // // readTask.Wait(); // // students = readTask.Result; // //} // else //web api sent error response // { // //log response status here.. // students = Enumerable.Empty<StudentViewModel>(); // ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); // } //} if (!string.IsNullOrEmpty(model.IdCampaign)) { SetSessionVariable("idCampaign", model.IdCampaign); } else if (!string.IsNullOrEmpty(filterValues) || pageIndex != 1) { model.IdCampaign = GetSessionVariable("idCampaign"); } ViewBag.CampaignList = _campaignBusiness.GetActiveCampaignsListDasboard(ApplicationUserCurrent.AccountId, Guid.Parse(ApplicationUserCurrent.UserId)).OrderBy(x => x.Name) .Select(c => new SelectListItem() { Value = _protectorCampaign.Protect(c.idcampaign.ToString()), Text = c.Name }); var filters = GetFilters(filterValues, deleteFilter); model = _homeBusiness.GetDashBoard(model, filters, pageIndex, pageSize, ApplicationUserCurrent.AccountId, _protectorCampaign); if (!string.IsNullOrEmpty(model.IdCampaign)) { model.IdCampaign = _protectorCampaign.Protect(model.IdCampaign); } ViewBag.Account = ApplicationUserCurrent.AccountId; ViewBag.user = ApplicationUserCurrent.UserId; return(View(model)); }