public IActionResult GetRptPurchaseBook() { IEnumerable <ReportPurchaseAndBookOutputModel> OutPutData = null; ReportPurchaseAndBookInputModel filter = new ReportPurchaseAndBookInputModel(); filter.PageSize = 1000; filter.PageNumber = 1; using (var client = new HttpClient()) { client.BaseAddress = new Uri(BaseAPI + "Dashboard/"); var responseTask = client.PostAsJsonAsync <ReportPurchaseAndBookInputModel>("ReportPurchaseAndBook", filter); responseTask.Wait(); var result = responseTask.Result; if (result.IsSuccessStatusCode) { var content = result.Content.ReadAsStringAsync(); ReportPurchaseAndModelResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <ReportPurchaseAndModelResponseModel>(content.Result); OutPutData = resutl.data; } else //web api sent error response { //log response status here.. OutPutData = Enumerable.Empty <ReportPurchaseAndBookOutputModel>(); ModelState.AddModelError(string.Empty, "Terjadi kesalahan. Mohon hubungi admin."); } } return(Json(OutPutData)); }
// 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 ReportPurchaseAndBookResultModel GetReportPurchaseAndBook(ReportPurchaseAndBookInputModel data) { string roleName = ""; UserBL userBL = new UserBL(db); if (data.UserName != null && data.UserName != string.Empty) { roleName = userBL.CheckRole(data.UserName); } var query = (from b in db.BookDetail join s in db.TitikLokasi on b.SiteID equals s.ID join sp in db.TitikLokasiPrice on b.PriceID equals sp.ID select new ReportPurchaseAndBookOutputModel() { BookID = b.ID, Harga = b.Price, HargaTotal = b.Qty * b.Price, OwnerSiteID = s.OwnerByUserID, Qty = b.Qty, NoBillBoard = s.NoBillboard, Status = b.StatusApprovalPerBillboard == 1 ? "Approve" : b.StatusApprovalPerBillboard == 2 ? "Reject" : "On Progress", Unit = sp.Dasar, StartDate = b.StartDate, EndDate = b.EndDate, BookNo = db.Book.Where(x => x.ID == b.BookID).FirstOrDefault().BookNo, UserName = db.User .Where(z => z.ID == db.Book .Where(x => x.ID == b.BookID).Select(x => x.UserID).FirstOrDefault()).Select(z => z.UserName).FirstOrDefault(), TglBook = b.CreateDate, TglTrans = db.Book.Where(x => x.ID == b.BookID).Select(x => x.PaymentID).FirstOrDefault() != null ? db.Payment.Where(x => x.ID == db.Book .Where(z => z.ID == b.BookID).Select(z => z.PaymentID).FirstOrDefault()).FirstOrDefault().CreateDate.ToString() : "" }); if (data.UserName != null && data.UserName != string.Empty) { query = (from q in query where q.UserName.Contains(data.UserName) select new ReportPurchaseAndBookOutputModel() { BookID = q.BookID, TglBook = q.TglBook, TglTrans = q.TglTrans, Harga = q.Harga, HargaTotal = q.HargaTotal, Qty = q.Qty, NoBillBoard = q.NoBillBoard, Status = q.Status, Unit = q.Unit, UserName = q.UserName }); } if (data.NoBillboard != null && data.NoBillboard != string.Empty) { query = (from q in query where q.NoBillBoard.Contains(data.NoBillboard) select new ReportPurchaseAndBookOutputModel() { BookID = q.BookID, TglBook = q.TglBook, TglTrans = q.TglTrans, Harga = q.Harga, HargaTotal = q.HargaTotal, Qty = q.Qty, NoBillBoard = q.NoBillBoard, Status = q.Status, Unit = q.Unit, UserName = q.UserName }); } if (data.IsBook != false) { query = (from q in query where q.Status == "On Progress" || q.Status == "Reject" select new ReportPurchaseAndBookOutputModel() { BookID = q.BookID, TglBook = q.TglBook, TglTrans = q.TglTrans, Harga = q.Harga, HargaTotal = q.HargaTotal, Qty = q.Qty, NoBillBoard = q.NoBillBoard, Status = q.Status, Unit = q.Unit, UserName = q.UserName }); } if (data.IsPurchased != false) { query = (from q in query where q.Status == "Approve" select new ReportPurchaseAndBookOutputModel() { BookID = q.BookID, TglBook = q.TglBook, TglTrans = q.TglTrans, Harga = q.Harga, HargaTotal = q.HargaTotal, Qty = q.Qty, NoBillBoard = q.NoBillBoard, Status = q.Status, Unit = q.Unit, UserName = q.UserName }); } if (data.TanggalPurchaseAwal != null) { query = (from q in query where q.TglBook >= data.TanggalPurchaseAwal select new ReportPurchaseAndBookOutputModel() { BookID = q.BookID, TglBook = q.TglBook, TglTrans = q.TglTrans, Harga = q.Harga, HargaTotal = q.HargaTotal, Qty = q.Qty, NoBillBoard = q.NoBillBoard, Status = q.Status, Unit = q.Unit, UserName = q.UserName }); } if (data.TanggalPurchaseAkhir != null) { query = (from q in query where q.TglBook <= data.TanggalPurchaseAwal select new ReportPurchaseAndBookOutputModel() { BookID = q.BookID, TglBook = q.TglBook, TglTrans = q.TglTrans, Harga = q.Harga, HargaTotal = q.HargaTotal, Qty = q.Qty, NoBillBoard = q.NoBillBoard, Status = q.Status, Unit = q.Unit, UserName = q.UserName }); } if (roleName == "MDO") { UserRepository userRepo = new UserRepository(db); var dataUser = userRepo.FindByUserName(data.UserName); query = query.Where(x => x.OwnerSiteID == dataUser.ID); } int pageNumber = data.PageNumber - 1; query = query.Skip(pageNumber * data.PageSize).Take(data.PageSize); ReportPurchaseAndBookResultModel result = new ReportPurchaseAndBookResultModel(); result.result = query.ToList(); result.TotalPages = (query.Count() / data.PageSize) + 1; result.TotalData = query.Count(); return(result); }
public ActionResult <ReportPurchaseAndModelResponseModel> ReportPurchaseAndBook([FromBody] ReportPurchaseAndBookInputModel data) { ReportPurchaseAndModelResponseModel res = new ReportPurchaseAndModelResponseModel(); try { ReportBL bl = new ReportBL(db); var temp = bl.GetReportPurchaseAndBook(data); res.data = temp.result; res.Message = "Success"; res.Response = true; res.TotalData = temp.TotalData; res.TotalPages = temp.TotalPages; return(res); } catch (Exception ex) { res.Message = ex.Message; res.Response = false; return(res); } }