Exemplo n.º 1
0
        public ReportProblemListResultModel GetProblem(ReportProblemListInputModel data)
        {
            var res = (from r in db.Report
                       join s in db.TitikLokasi on r.SiteID equals s.ID
                       join u in db.User on r.UserID equals u.ID
                       select new ReportProblemListOutputModel
            {
                ReportNo = r.ReportNo,
                Desc = r.Desc,
                From = u.UserName,
                NoBillboard = s.NoBillboard,
                ReportProblemID = r.ID,
                IsToSPV = r.isToSPV,
            });

            if (data.IsToSPV)
            {
                res = res.Where(x => x.IsToSPV);
            }

            int pageNumber = data.PageNumber - 1;

            res = res.Skip(pageNumber * data.PageSize).Take(data.PageSize);

            ReportProblemListResultModel result = new ReportProblemListResultModel();

            result.data       = res.ToList();
            result.TotalPages = (res.Count() / data.PageSize) + 1;
            result.TotalData  = res.Count();


            return(result);
        }
Exemplo n.º 2
0
        // 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"));
            }
        }
Exemplo n.º 3
0
        public ActionResult <ReportProblemListResponseModel> ViewReportProblemSiteList([FromBody] ReportProblemListInputModel data)
        {
            ReportProblemListResponseModel res = new ReportProblemListResponseModel();

            try
            {
                ReportBL bl   = new ReportBL(DbContext);
                var      temp = bl.GetProblem(data);

                res.data     = temp.data;
                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);
            }
        }