public IActionResult ReportRekapBox() { RekapKotakEmpatOutputModel OutPutData = null; ReportKotaEmpatInputModel filter = new ReportKotaEmpatInputModel(); if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { filter.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID)); using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Dashboard/"); var responseTask = client.PostAsJsonAsync <ReportKotaEmpatInputModel>("ReportRekapBox", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); RekapKotakEmpatResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <RekapKotakEmpatResponseModel>(content.Result); OutPutData = resutl.data; } else //web api sent error response { //log response status here.. ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } } return(Json(OutPutData)); }
public ActionResult <RekapKotakEmpatResponseModel> ReportRekapBox([FromBody] ReportKotaEmpatInputModel data) { RekapKotakEmpatResponseModel res = new RekapKotakEmpatResponseModel(); try { ReportBL bl = new ReportBL(db); var temp = bl.GetKotakEmpat(data); res.data = temp; res.Message = "Success"; res.Response = true; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }
// GET: /<controller>/ public IActionResult Index() { int PageSize = 1000; int PageNumber = 1; if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "") { CustomDashboard CustomOutPut = new CustomDashboard(); CustomOutPut.KotakEmpat = new RekapKotakEmpatOutputModel(); CustomOutPut.PurchaseAndBook = new List <ReportPurchaseAndBookOutputModel>(); CustomOutPut.Chard = new ChardModel(); CustomOutPut.SiteProblem = new List <ReportProblemListOutputModel>(); ReportKotaEmpatInputModel filter1 = new ReportKotaEmpatInputModel(); ReportPurchaseAndBookInputModel filter2 = new ReportPurchaseAndBookInputModel(); ReportProblemListInputModel filter3 = new ReportProblemListInputModel(); if (HttpContext.Session.GetString(SessionKeyRole) != "ADM" && HttpContext.Session.GetString(SessionKeyRole) != "SPV") { filter1.UserID = Guid.Parse(HttpContext.Session.GetString(SessionKeyID)); filter2.UserName = HttpContext.Session.GetString(SessionKeyName); } filter2.PageSize = PageSize; filter2.PageNumber = PageNumber; filter3.isToSPV = true; filter3.PageSize = PageSize; filter3.PageNumber = PageNumber; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Dashboard/"); var responseTask = client.PostAsJsonAsync <ReportKotaEmpatInputModel>("ReportRekapBox", filter1); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); RekapKotakEmpatResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <RekapKotakEmpatResponseModel>(content.Result); if (resutl.data != null) { CustomOutPut.KotakEmpat.TotalUseSite = resutl.data.TotalUseSite; CustomOutPut.KotakEmpat.TotalSite = resutl.data.TotalSite; CustomOutPut.KotakEmpat.Revenue = resutl.data.Revenue; CustomOutPut.KotakEmpat.TotalRevenue = resutl.data.TotalRevenue; CustomOutPut.KotakEmpat.TotalBooking = resutl.data.TotalBooking; CustomOutPut.KotakEmpat.TotalOrder = resutl.data.TotalOrder; } } else //web api sent error response { //log response status here.. ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } using (var client1 = new HttpClient()) { client1.BaseAddress = new Uri(BaseAPI + "Dashboard/"); var responseTask1 = client1.PostAsJsonAsync <ReportPurchaseAndBookInputModel>("ReportPurchaseAndBook", filter2); responseTask1.Wait(); var result1 = responseTask1.Result; if (result1.IsSuccessStatusCode) { var content = result1.Content.ReadAsStringAsync(); ReportPurchaseAndModelResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportPurchaseAndModelResponseModel>(content.Result); CustomOutPut.PurchaseAndBook = resutl.data; } else //web api sent error response { //log response status here.. ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } using (var client2 = new HttpClient()) { client2.BaseAddress = new Uri(BaseAPI + "Dashboard/"); var responseTask1 = client2.PostAsync("ReportChartBookPerMonth", null); responseTask1.Wait(); var result1 = responseTask1.Result; if (result1.IsSuccessStatusCode) { var content = result1.Content.ReadAsStringAsync(); ChardResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ChardResponseModel>(content.Result); CustomOutPut.Chard = resutl.data; } else //web api sent error response { //log response status here.. ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } using (var client3 = new HttpClient()) { client3.BaseAddress = new Uri(BaseAPI + "Admin/"); var responseTask1 = client3.PostAsJsonAsync <ReportProblemListInputModel>("ViewReportProblemSiteList", filter3); responseTask1.Wait(); var result1 = responseTask1.Result; if (result1.IsSuccessStatusCode) { var content = result1.Content.ReadAsStringAsync(); ReportProblemListResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportProblemListResponseModel>(content.Result); CustomOutPut.SiteProblem = resutl.data; } else //web api sent error response { //log response status here.. ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } return(View(CustomOutPut)); } else { TempData["CustomError"] = "Silakan masuk sebelum menggunakan situs web."; //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("OwnerLogon", "Login"); //} return(RedirectToAction("Logon", "Login")); } }
public RekapKotakEmpatOutputModel GetKotakEmpat(ReportKotaEmpatInputModel data) { RekapKotakEmpatOutputModel outputModel = new RekapKotakEmpatOutputModel(); DateTime today = DateTime.Now; int totalBooking = 0; if (data.UserID != null && data.UserID != Guid.Empty) { totalBooking = db.Book.Count(x => x.UserID == data.UserID); } else { totalBooking = db.Book.Count(); } int totalOrder = 0; if (data.UserID != null && data.UserID != Guid.Empty) { totalOrder = db.Book.Count(x => x.PaymentID != Guid.Empty && x.UserID == data.UserID); } else { totalOrder = db.Book.Count(x => x.PaymentID != Guid.Empty); } int totalUseSite = 0; if (data.UserID != null && data.UserID != Guid.Empty) { //totalUseSite = db.BookDetail.Where(x => x.EndDate <= DateTime.Now && x.CreateDate.Month == today.Month).GroupBy(x => x.SiteItemID).Count(); totalUseSite = (from bd in db.BookDetail join s in db.TitikLokasi on bd.SiteID equals s.ID where bd.EndDate <= DateTime.Now && bd.CreateDate.Month == today.Month && s.OwnerByUserID == data.UserID select new { SiteID = bd.SiteID }).Distinct().Count(); } else { totalUseSite = (from bd in db.BookDetail join s in db.TitikLokasi on bd.SiteID equals s.ID where bd.EndDate <= DateTime.Now && bd.CreateDate.Month == today.Month select new { SiteID = bd.SiteID }).Distinct().Count(); } int totalSite = 0; if (data.UserID != null && data.UserID != Guid.Empty) { totalSite = db.TitikLokasi.Where(x => x.DeletedDate == null && x.OwnerByUserID == data.UserID).Count(); } else { totalSite = db.TitikLokasi.Where(x => x.DeletedDate == null).Count(); } outputModel.TotalBooking = totalBooking; outputModel.TotalOrder = totalOrder; outputModel.TotalUseSite = totalUseSite; outputModel.TotalSite = totalSite; var dataRevenue = (from b in db.Book from bd in db.BookDetail.Where(d => d.BookID == b.ID).DefaultIfEmpty() join p in db.Payment on b.PaymentID equals p.ID join s in db.TitikLokasi on bd.SiteID equals s.ID where b.CreateDate.Month == today.Month select new Revenue() { //TotalRevenue = db.BookDetail.Where(d => d.BookID == b.ID).Sum(o => o.FinalPrice != 0 ? o.FinalPrice : o.Price), TotalRevenue = bd.FinalPrice != 0 ? bd.FinalPrice : bd.Price, PartRevenue = p.TotalPaid, UserID = s.OwnerByUserID }); if (data.UserID != null && data.UserID != Guid.Empty) { dataRevenue = dataRevenue.Where(x => x.UserID == data.UserID); } outputModel.TotalRevenue = dataRevenue.Sum(x => x.TotalRevenue); outputModel.Revenue = dataRevenue.Sum(x => x.PartRevenue); return(outputModel); }