示例#1
0
        public IActionResult ReportToSPV()
        {
            AddReportProblemOutputModel OutPutData = new AddReportProblemOutputModel();
            AddReportProblemInputModel  filter     = new AddReportProblemInputModel();

            filter.UserID  = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
            filter.SiteID  = Guid.Parse("");
            filter.Desc    = "";
            filter.isToSPV = true;
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(BaseAPI + "MediaBuyer/");
                var responseTask = client.PostAsJsonAsync <AddReportProblemInputModel>("ReportToSPV", filter);
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var content = result.Content.ReadAsStringAsync();
                    AddReportProblemResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <AddReportProblemResponseModel>(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 <AddReportProblemResponseModel> ReportToSPV([FromBody] AddReportProblemInputModel data)
        {
            AddReportProblemResponseModel res = new AddReportProblemResponseModel();

            try
            {
                ReportBL bl = new ReportBL(DbContext);

                //artinya ini report di kirim ke SPV/Admin
                //kalau false berarti kebalikannya
                data.isToSPV = true;

                var temp = bl.Save(data);

                res.data     = temp;
                res.Message  = "Success";
                res.Response = true;

                return(res);
            }
            catch (Exception ex)
            {
                res.Message  = ex.Message;
                res.Response = false;

                return(res);
            }
        }
示例#3
0
        public ActionResult ReportSite(string siteID, string desc)
        {
            AddReportProblemOutputModel OutPutData = new AddReportProblemOutputModel();

            if (HttpContext.Session.GetString(SessionKeyID) != null && HttpContext.Session.GetString(SessionKeyID) != "")
            {
                AddReportProblemInputModel siteData = new AddReportProblemInputModel();
                siteData.isToSPV = true;
                siteData.SiteID  = Guid.Parse(siteID);
                siteData.UserID  = Guid.Parse(HttpContext.Session.GetString(SessionKeyID));
                siteData.Desc    = desc;

                JsonConvert.SerializeObject(siteData);
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(BaseAPI + "MediaBuyer/");
                    //HTTP POST
                    var postTask = client.PostAsJsonAsync <AddReportProblemInputModel>("ReportToSPV", siteData);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var content = result.Content.ReadAsStringAsync();
                        AddReportProblemResponseModel resutl = Newtonsoft.Json.JsonConvert.DeserializeObject <AddReportProblemResponseModel>(content.Result);
                        OutPutData = resutl.data;
                    }
                    else
                    {
                        TempData["CustomError"] = "Fail to add data. Please contact administrator.";
                    }
                }
                return(Json(OutPutData));
            }
            else
            {
                TempData["CustomError"] = "Please login before using the 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("BuyerLogon", "Login"));
                }
                //return RedirectToAction("Logon", "Login");
            }
        }