public async Task <ActionResult> InfinateScrollAsync(int BlockNumber, int Pages, string tipeBillboard = "", string provinsi = "", string kota = "", double minharga = 0, double maxharga = 0) { int BlockSize = 250; int totalData = 0; var Mapsdata = new ForMaps(); var cities = new List <City>(); var BillBoards = new List <BillboardDetail>(); //IEnumerable<SiteListOutputModel> sites = null; List <SiteListOutputModel> sites = new List <SiteListOutputModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Site/"); FilterBillboard filter = new FilterBillboard(); if (HttpContext.Session.GetString(SessionKeyRole) == null || HttpContext.Session.GetString(SessionKeyRole) == "" || HttpContext.Session.GetString(SessionKeyRole) == "ADM") { filter.UserID = Guid.Empty; } else { filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID)); } filter.TypeBillboard = tipeBillboard != null ? tipeBillboard : ""; filter.Province = provinsi != null && provinsi.Split("|").Length > 1 ? provinsi.Split("|")[1] : ""; filter.City = kota != null ? kota : ""; filter.Latitude = ""; filter.Longitude = ""; filter.MinimumPrice = minharga; filter.MaximumPrice = maxharga; filter.showWithDisabledSite = false; filter.FilterDataTableValue = ""; filter.PageNumber = BlockNumber; filter.PageSize = 100; var responseTask = client.PostAsJsonAsync <FilterBillboard>("GetListSite", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); SiteListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <SiteListResponseModel>(content.Result); totalData = resutl.TotalData; sites = resutl.data; foreach (var p in sites) { var city = new City(); var BillBoard = new BillboardDetail(); if (p.NoBillboard != null && p.Latitude != null && p.Longitude != null && p.NoBillboard != "" && p.Latitude != "" && p.Longitude != "") { city.Title = p.NoBillboard; city.Lat = double.Parse(p.Latitude, System.Globalization.CultureInfo.InvariantCulture); city.Lng = double.Parse(p.Longitude, System.Globalization.CultureInfo.InvariantCulture); city.Kota = p.Kota; city.Prov = p.Provinsi; city.HorV = p.HorV; city.Tipe = p.Tipe; city.Rate = p.RateScoreAverage; city.Price = p.HargaPerhari.ToString("N"); city.Image = "../image/NoImage.jpg"; BillBoard.SiteID = p.SiteID.ToString(); BillBoard.NoBillBoard = p.NoBillboard; BillBoard.Kota = p.Kota; BillBoard.Cab = p.Cabang; BillBoard.HorV = p.HorV; BillBoard.Tipe = p.Tipe; BillBoard.Lat = double.Parse(p.Latitude, System.Globalization.CultureInfo.InvariantCulture); BillBoard.Lng = double.Parse(p.Longitude, System.Globalization.CultureInfo.InvariantCulture); BillBoard.Pjg = 0; BillBoard.Lbr = 0; BillBoard.Hawl = 0; BillBoard.Hahr = 0; BillBoard.Img = "-"; BillBoard.RateScoreAvg = p.RateScoreAverage; BillBoard.Alamat = p.Alamat; if (p.ImageHeader != null && p.ImageHeader.Contains("/Upload")) { BillBoard.Img = p.ImageHeader; city.Image = p.ImageHeader; } if (p.SiteItem != null && p.SiteItem.Count > 0) { BillBoard.SiteItemID = p.SiteItem[0].SiteItemID.ToString(); BillBoard.Pjg = p.SiteItem[0].Panjang; BillBoard.Lbr = p.SiteItem[0].Lebar; if (p.SiteItem[0].Price != null && p.SiteItem[0].Price.Count > 0) { BillBoard.Hawl = p.SiteItem[0].Price[0].HargaAwal; BillBoard.Hahr = p.SiteItem[0].Price[0].HargaAkhir; } //if (p.SiteItem[0].Image != null && p.SiteItem[0].Image.Count > 0) //{ // BillBoard.Img = p.SiteItem[0].Image[0].Image; //} } } cities.Add(city); BillBoards.Add(BillBoard); } Mapsdata.Cities = cities; Mapsdata.BillBoard = BillBoards; } } JsonModel jsonModel = new JsonModel(); jsonModel.NoMoreData = (totalData / BlockSize) == BlockNumber; if (Pages == 1) { jsonModel.HTMLString = await RenderPartialViewToString("PartialList", Mapsdata); } else if (Pages == 2) { jsonModel.HTMLString = await RenderPartialViewToString("PartialCompare", Mapsdata); } return(Json(jsonModel)); }
public IActionResult Index(string tipeBillboard, string provinsi, string kota, double minharga = 0, double maxharga = 0) { if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { HttpContext.Session.SetString(SessionKeyDomain, Domain); var Mapsdata = new ForMaps(); var cities = new List <City>(); var BillBoards = new List <BillboardDetail>(); //IEnumerable<SiteListOutputModel> sites = null; List <SiteListOutputModel> sites = new List <SiteListOutputModel>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Site/"); FilterBillboard filter = new FilterBillboard(); if (HttpContext.Session.GetString(SessionKeyRole) == null || HttpContext.Session.GetString(SessionKeyRole) == "" || HttpContext.Session.GetString(SessionKeyRole) == "ADM") { filter.UserID = Guid.Empty; } else { filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID)); } filter.TypeBillboard = tipeBillboard != null ? tipeBillboard : ""; filter.Province = provinsi != null && provinsi.Length > 0 ? provinsi.Split("|")[1] : ""; filter.City = kota != null ? kota : ""; filter.Latitude = ""; filter.Longitude = ""; filter.MinimumPrice = minharga; filter.MaximumPrice = maxharga; filter.showWithDisabledSite = false; filter.FilterDataTableValue = ""; filter.PageNumber = 1; filter.PageSize = 250; var responseTask = client.PostAsJsonAsync <FilterBillboard>("GetListSite", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); SiteListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <SiteListResponseModel>(content.Result); sites = resutl.data; foreach (var p in sites) { var city = new City(); var BillBoard = new BillboardDetail(); if (p.NoBillboard != null && p.Latitude != null && p.Longitude != null && p.NoBillboard != "" && p.Latitude != "" && p.Longitude != "") { city.Title = p.NoBillboard; city.Lat = double.Parse(p.Latitude, System.Globalization.CultureInfo.InvariantCulture); city.Lng = double.Parse(p.Longitude, System.Globalization.CultureInfo.InvariantCulture); city.Kota = p.Kota; city.Prov = p.Provinsi; city.HorV = p.HorV; city.Tipe = p.Tipe; city.Rate = p.RateScoreAverage; city.Price = p.HargaPerhari.ToString("N"); city.Image = "../image/NoImage.jpg"; BillBoard.SiteID = p.SiteID.ToString(); BillBoard.NoBillBoard = p.NoBillboard; BillBoard.Kota = p.Kota; BillBoard.Cab = p.Cabang; BillBoard.HorV = p.HorV; BillBoard.Tipe = p.Tipe; BillBoard.Lat = double.Parse(p.Latitude, System.Globalization.CultureInfo.InvariantCulture); BillBoard.Lng = double.Parse(p.Longitude, System.Globalization.CultureInfo.InvariantCulture); BillBoard.Pjg = 0; BillBoard.Lbr = 0; BillBoard.Hawl = 0; BillBoard.Hahr = 0; BillBoard.Img = "-"; BillBoard.RateScoreAvg = p.RateScoreAverage; BillBoard.Alamat = p.Alamat; if (p.ImageHeader != null && p.ImageHeader.Contains("/Upload")) { BillBoard.Img = p.ImageHeader; city.Image = p.ImageHeader; } if (p.SiteItem != null && p.SiteItem.Count > 0) { BillBoard.SiteItemID = p.SiteItem[0].SiteItemID.ToString(); BillBoard.Pjg = p.SiteItem[0].Panjang; BillBoard.Lbr = p.SiteItem[0].Lebar; if (p.SiteItem[0].Price != null && p.SiteItem[0].Price.Count > 0) { BillBoard.Hawl = p.SiteItem[0].Price[0].HargaAwal; BillBoard.Hahr = p.SiteItem[0].Price[0].HargaAkhir; } //if (p.SiteItem[0].Image != null && p.SiteItem[0].Image.Count > 0) //{ // BillBoard.Img = p.SiteItem[0].Image[0].Image; // city.Image = p.SiteItem[0].Image[0].Image; //} } } cities.Add(city); BillBoards.Add(BillBoard); } Mapsdata.Cities = cities; Mapsdata.BillBoard = BillBoards; #region Old //filter.PageSize = resutl.TotalPages; //var reresponse = client.PostAsJsonAsync<FilterBillboard>("GetListSite", filter); //reresponse.Wait(); //var reresult = reresponse.Result; //if (reresult.IsSuccessStatusCode) //{ // var recontent = reresult.Content.ReadAsStringAsync(); // SiteListResponseModel fnlresult = Newtonsoft.Json.JsonConvert.DeserializeObject<SiteListResponseModel>(recontent.Result); // sites = fnlresult.data; // foreach (var p in sites) // { // var city = new City(); // var BillBoard = new BillboardDetail(); // if (p.NoBillboard != null && p.Latitude != null && p.Longitude != null && p.NoBillboard != "" && p.Latitude != "" && p.Longitude != "") // { // city.Title = p.NoBillboard; // city.Lat = double.Parse(p.Latitude, System.Globalization.CultureInfo.InvariantCulture); // city.Lng = double.Parse(p.Longitude, System.Globalization.CultureInfo.InvariantCulture); // BillBoard.SiteID = p.SiteID.ToString(); // BillBoard.NoBillBoard = p.NoBillboard; // BillBoard.Kota = p.Kota; // BillBoard.Cab = p.Cabang; // BillBoard.HorV = p.HorV; // BillBoard.Tipe = p.Tipe; // BillBoard.Lat = double.Parse(p.Latitude, System.Globalization.CultureInfo.InvariantCulture); // BillBoard.Lng = double.Parse(p.Longitude, System.Globalization.CultureInfo.InvariantCulture); // BillBoard.Pjg = 0; // BillBoard.Lbr = 0; // BillBoard.Hawl = 0; // BillBoard.Hahr = 0; // BillBoard.Img = "-"; // BillBoard.RateScoreAvg = p.RateScoreAverage; // BillBoard.Alamat = p.Alamat; // if (p.SiteItem != null && p.SiteItem.Count > 0) // { // BillBoard.SiteItemID = p.SiteItem[0].SiteItemID.ToString(); // BillBoard.Pjg = p.SiteItem[0].Panjang; // BillBoard.Lbr = p.SiteItem[0].Lebar; // if (p.SiteItem[0].Price != null && p.SiteItem[0].Price.Count > 0) // { // BillBoard.Hawl = p.SiteItem[0].Price[0].HargaAwal; // BillBoard.Hahr = p.SiteItem[0].Price[0].HargaAkhir; // } // if (p.SiteItem[0].Image != null && p.SiteItem[0].Image.Count > 0) // { // BillBoard.Img = p.SiteItem[0].Image[0].Image; // } // } // } // cities.Add(city); // BillBoards.Add(BillBoard); // } // Mapsdata.Cities = cities; // Mapsdata.BillBoard = BillBoards; //} #endregion } else //web api sent error response { //cities.Add(new City() { Title = "Paris", Lat = 48.855901, Lng = 2.349272 }); //cities.Add(new City() { Title = "Berlin", Lat = 52.520413, Lng = 13.402794 }); //cities.Add(new City() { Title = "Rome", Lat = 41.907074, Lng = 12.498474 }); cities.Add(new City() { Title = "Paris", Lat = 48.855901, Lng = 2.349272, Kota = "", Prov = "", HorV = "", Tipe = "", Rate = 0, Price = "0", Image = "~/image/NoImage.jpg" }); cities.Add(new City() { Title = "Berlin", Lat = 52.520413, Lng = 13.402794, Kota = "", Prov = "", HorV = "", Tipe = "", Rate = 0, Price = "0", Image = "~/image/NoImage.jpg" }); cities.Add(new City() { Title = "Rome", Lat = 41.907074, Lng = 12.498474, Kota = "", Prov = "", HorV = "", Tipe = "", Rate = 0, Price = "0", Image = "~/image/NoImage.jpg" }); Mapsdata.Cities = cities; Mapsdata.BillBoard = BillBoards; //log response status here.. //sites = Enumerable.Empty<SiteListOutputModel>(); ModelState.AddModelError(string.Empty, "Server error. Please contact administrator."); } } return(View(Mapsdata)); } else { if (HttpContext.Session.GetString(Loginfrom) == "ADM/SPV") { return(RedirectToAction("AdminLogon", "Login")); } else if (HttpContext.Session.GetString(Loginfrom) == "MDO") { return(RedirectToAction("OwnerLogon", "Login")); } else { return(RedirectToAction("BuyerLogon", "Login")); } //return RedirectToAction("Logon", "Login"); } }
public IActionResult ViewCompare() { List <CompareListResultModel> OutPutData = new List <CompareListResultModel>(); StringBuilder sb = new StringBuilder(); CompareListInputModel filter = new CompareListInputModel(); filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID)); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Site/"); var responseTask = client.PostAsJsonAsync <CompareListInputModel>("ViewCompare", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); CompareListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <CompareListResponseModel>(content.Result); OutPutData = resutl.data; if (OutPutData.Count > 3) { for (int j = 0; j < 3; j++) { var quote = "'"; sb.Append("<div class='column'>"); BillboardDetail dataBillboard = new BillboardDetail(); if (OutPutData[j].Item != null && OutPutData[j].Item.Count > 0) { var item = OutPutData[j].Item; foreach (CompareListSiteItemModel data in item) { dataBillboard.Pjg = data.Panjang; dataBillboard.Lbr = data.Lebar; if (data.Price != null) { dataBillboard.Hawl = data.Price[0].HargaAwal; dataBillboard.Hahr = data.Price[0].HargaAkhir; } else { dataBillboard.Hawl = 0; dataBillboard.Hahr = 0; } if (data.Image != null && data.Image.Count > 0) { dataBillboard.Img = data.Image[0].Image; } else { dataBillboard.Img = "-"; } } } if (OutPutData[j].Detail != null) { if (dataBillboard.Img == "-") { sb.Append("<div class='viewprod'>Photo not available</div>"); } else { sb.Append("<img src='" + dataBillboard.Img + "' class='listimage'/>"); } sb.Append("<div class='detailprod'>"); sb.Append("<p class='pheader'>" + OutPutData[j].Detail.NoBillboard + "</p>"); sb.Append("<p class='pdetail'>Alamat Lokasi Billboard</p>"); sb.Append("<p class='pdetail'>Tipe : " + OutPutData[j].Detail.Tipe + "</p>"); sb.Append("<p class='pdetail'>Ukuran : " + dataBillboard.Pjg + " X " + dataBillboard.Lbr + "</p>"); sb.Append("<p class='pdetail'>H/V : " + OutPutData[j].Detail.HorV + "</p>"); sb.Append("</div>"); sb.Append("<div class='detailprice'>"); sb.Append("<p>Rp. <span class='price'>" + Convert.ToDecimal(dataBillboard.Hawl).ToString("#,##0") + "</span>,-</p>"); sb.Append("</div>"); sb.Append("<div class='detailbtn'>"); if (Domain != "") { sb.Append("<input type=\"button\" value=\"Delete\" style=\"padding: 5px 10px; font - size: 15px; margin: 5px 5px;\" onclick=\"deleteCompare('/" + Domain + "/Rest/DeleteFromCompare','" + OutPutData[j].Detail.CompareID + "')\" />"); } else { sb.Append("<input type=\"button\" value=\"Delete\" style=\"padding: 5px 10px; font - size: 15px; margin: 5px 5px;\" onclick=\"deleteCompare('/Rest/DeleteFromCompare','" + OutPutData[j].Detail.CompareID + "')\" />"); } sb.Append("</div>"); } sb.Append("</div>"); } } else { for (int j = 0; j < OutPutData.Count; j++) { var quote = "'"; sb.Append("<div class='column'>"); BillboardDetail dataBillboard = new BillboardDetail(); if (OutPutData[j].Item != null && OutPutData[j].Item.Count > 0) { var item = OutPutData[j].Item; foreach (CompareListSiteItemModel data in item) { dataBillboard.Pjg = data.Panjang; dataBillboard.Lbr = data.Lebar; if (data.Price != null) { dataBillboard.Hawl = data.Price[0].HargaAwal; dataBillboard.Hahr = data.Price[0].HargaAkhir; } else { dataBillboard.Hawl = 0; dataBillboard.Hahr = 0; } if (data.Image != null && data.Image.Count > 0) { dataBillboard.Img = data.Image[0].Image; } else { dataBillboard.Img = "-"; } } } if (OutPutData[j].Detail != null) { if (dataBillboard.Img == "-") { sb.Append("<div class='viewprod'>Photo not available</div>"); } else { sb.Append("<img src='" + dataBillboard.Img + "' class='listimage'/>"); } sb.Append("<div class='detailprod'>"); sb.Append("<p class='pheader'>" + OutPutData[j].Detail.NoBillboard + "</p>"); sb.Append("<p class='pdetail'>Alamat Lokasi Billboard</p>"); sb.Append("<p class='pdetail'>Tipe : " + OutPutData[j].Detail.Tipe + "</p>"); sb.Append("<p class='pdetail'>Ukuran : " + dataBillboard.Pjg + " X " + dataBillboard.Lbr + "</p>"); sb.Append("<p class='pdetail'>H/V : " + OutPutData[j].Detail.HorV + "</p>"); sb.Append("</div>"); sb.Append("<div class='detailprice'>"); sb.Append("<p>Rp. <span class='price'>" + Convert.ToDecimal(dataBillboard.Hawl).ToString("#,##0") + "</span>,-</p>"); sb.Append("</div>"); sb.Append("<div class='detailbtn'>"); if (Domain != "") { sb.Append("<input type=\"button\" value=\"Delete\" style=\"padding: 5px 10px; font - size: 15px; margin: 5px 5px;\" onclick=\"deleteCompare('/" + Domain + "/Rest/DeleteFromCompare','" + OutPutData[j].Detail.CompareID + "')\" />"); } else { sb.Append("<input type=\"button\" value=\"Delete\" style=\"padding: 5px 10px; font - size: 15px; margin: 5px 5px;\" onclick=\"deleteCompare('/Rest/DeleteFromCompare','" + OutPutData[j].Detail.CompareID + "')\" />"); } sb.Append("</div>"); } sb.Append("</div>"); } } return(this.Content(sb.ToString())); } else //web api sent error response { //log response status here.. //OutPutData = Enumerable.Empty<CompareListResultModel>(); ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } return(Json(OutPutData)); }