// GET: RetrivalInvalid public ActionResult Index(string searchString, int page = 1, int size = 10) { List <RETRIVAL_INVALID> list = new List <RETRIVAL_INVALID>(); HttpClient client = new AccessAPI().Access(); if (String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/GetAllRetrivalInvalid")).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } var listRetrival = list.ToPagedList(page, size); return(View(listRetrival)); } else { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/FindRetrivalInvalid?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } @ViewBag.searchString = searchString; var listRetrival = list.ToPagedList(page, size); return(View(listRetrival)); } }
public ActionResult ViewMessage(string id) { var user = GetUserName(); MESSAGE message = new MESSAGE(); HttpClient client = new AccessAPI().Access(); StringContent content = new StringContent(""); HttpResponseMessage response = client.GetAsync(string.Format("api/MESSAGE/GetMESSAGE/{0}", id)).Result; if (response.IsSuccessStatusCode) { message = response.Content.ReadAsAsync <MESSAGE>().Result; if (message.Receiver != "ALL" && message.Receiver != "all" && user.UserName != message.Sender) { HttpResponseMessage response1 = client.PostAsync(string.Format("api/MESSAGE/UpdateIsRead?ID={0}", id), content).Result; bool check = response1.IsSuccessStatusCode; } } HttpResponseMessage response2 = client.GetAsync(string.Format("api/MESSAGETYPE/CountUnreadMessage?MaCode={0}&UserType={1}", user.UserName, user.UserType)).Result; if (response2.IsSuccessStatusCode) { int number = response2.Content.ReadAsAsync <int>().Result; Session.Add(CommonConstants.NUMBER_UNREAD_MESSAGE, number); } return(View(message)); }
public ActionResult ExportPDF(string searchString) { var list = new List <RETRIVAL_INVALID>(); string footer = "--footer-right \"Date: [date] [time]\" " + "--footer-center \"Page: [page] of [toPage]\" --footer-line --footer-font-size \"9\" --footer-spacing 5 --footer-font-name \"calibri light\""; var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (!String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/FindRetrivalInvalid?searchString={0}", searchString)).Result; list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } else { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/GetAllRetrivalInvalid")).Result; list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } return(new Rotativa.PartialViewAsPdf("RetrivalError", list) { //RetrivalInvalid FileName = "RetrivalInvalid.pdf", CustomSwitches = footer }); }
// GET: RetrivalInvalid public ActionResult Index(string searchString, int page = 1, int size = 10) { List <RETRIVAL_INVALID> list = new List <RETRIVAL_INVALID>(); HttpClient client = new AccessAPI().Access(); int totalPage = 0; int maxPage = 4; int totalRetrival = 0; //HttpClient client = new HttpClient(); //client.BaseAddress = new Uri("http://localhost:21212/"); HttpResponseMessage response1 = client.GetAsync(string.Format("api/RETRIVAL_INVALID/CountRetrivalInvalid")).Result; if (response1.IsSuccessStatusCode) { totalRetrival = response1.Content.ReadAsAsync <int>().Result; } //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); if (String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/FindAllRetrivalInvalid?pageIndex={0}&pageSize={1}", page - 1, size)).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; totalPage = (int)Math.Ceiling((double)totalRetrival / size); ViewBag.Total = totalRetrival; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } return(View(list.ToList())); } else { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/FindRetrivalInvalidElement?searchString={0}&pageIndex={1}&pageSize={2}", searchString, page - 1, size)).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; HttpResponseMessage response2 = client.GetAsync(string.Format("api/RETRIVAL_INVALID/CountRetrivalInvalidElement?searchString={0}", searchString)).Result; if (response2.IsSuccessStatusCode) { totalRetrival = response2.Content.ReadAsAsync <int>().Result; } totalPage = (int)Math.Ceiling((double)totalRetrival / size); ViewBag.Total = totalRetrival; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } @ViewBag.searchString = searchString; return(View(list.ToList())); } }
public ActionResult ExportCSV(string searchString) { List <RETRIVAL> list = new List <RETRIVAL>(); HttpClient client = new AccessAPI().Access(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View("Index")); } if (!String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/Retrival/FindRetrivalElement_Print?searchString={0}", searchString)).Result; list = response.Content.ReadAsAsync <List <RETRIVAL> >().Result; } else { HttpResponseMessage response = client.GetAsync(string.Format("api/Retrival/FindAllRetrival_Print")).Result; list = response.Content.ReadAsAsync <List <RETRIVAL> >().Result; } StringWriter sw = new StringWriter(); sw.WriteLine("Retrival Code,Account Number,Merchant Code,Transaction Code,Transaction Date,Report Date,Amount"); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=RETRIVAL.csv"); Response.ContentType = "text/csv"; //var csv = new CsvWriter(sw); foreach (var item in list) { sw.WriteLine(String.Format("{0},{1},{2},{3},{4},{5},{6}", item.RetrivalCode.ToString(), item.AccountNumber.ToString(), item.MerchantCode.ToString(), item.TransactionCode.ToString(), item.TransactionDate.ToString(), item.ReportDate.ToString(), item.Amout.ToString())); } Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return(View("Index")); }
public ActionResult ExportExcel(string searchString) { List <RETRIVAL> list = new List <RETRIVAL>(); HttpClient client = new AccessAPI().Access(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View("Index")); } if (!String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/Retrival/FindRetrivalElement_Print?searchString={0}", searchString)).Result; list = response.Content.ReadAsAsync <List <RETRIVAL> >().Result; } else { HttpResponseMessage response = client.GetAsync(string.Format("api/Retrival/FindAllRetrival_Print")).Result; list = response.Content.ReadAsAsync <List <RETRIVAL> >().Result; } var gv = new GridView(); gv.DataSource = list; gv.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=RETRIVAL.xls"); Response.ContentType = "appliation/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); gv.RenderControl(tw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return(View("Index")); }
public ActionResult Edit() { var model = Session[CommonConstants.USER_SESSION]; //khai báo 1 session bên common giống như bên Cart var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); var user = (USER_INFORMATION)Session[CommonConstants.USER_SESSION]; var pass = Session[CommonConstants.HASH_PASSWORD]; StringContent content = new StringContent("username="******"&password="******"&grant_type=password"); HttpResponseMessage res = client.PostAsync(string.Format("api/security/token"), content).Result; TokenModel token = res.Content.ReadAsAsync <TokenModel>().Result; client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + token.access_token); HttpResponseMessage response = client.GetAsync(string.Format("api/AGENT/FindAgent?agentCode={0}", temp.UserName)).Result; var agent = new AGENT(); if (response.IsSuccessStatusCode) { agent = response.Content.ReadAsAsync <AGENT>().Result; //return RedirectToAction("Index", "Home"); } return(View(agent)); }
public ActionResult ViewDetail_Retrival() { RETRIVAL list = new RETRIVAL(); HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL/FindRetrival?RetrivalCode={0}", Request.QueryString["Retrivalcode"])).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync<RETRIVAL>().Result; } return View(list); }
public ActionResult ExportCSV(string searchString) { var list = getAllRetrivalInvalid().ToList(); HttpClient client = new AccessAPI().Access(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (!String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/FindRetrivalInvalid?searchString={0}", searchString)).Result; list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } else { HttpResponseMessage response = client.GetAsync(string.Format("api/RETRIVAL_INVALID/GetAllRetrivalInvalid")).Result; list = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } StringWriter sw = new StringWriter(); sw.WriteLine("Retrival Code,Account Number,Merchant Code,Transaction Code,Tracsaction Date,Report Date,Amount, Error Message"); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=Retrival_Invalid.csv"); Response.ContentType = "text/csv"; var csv = new CsvWriter(sw); foreach (var item in list) { csv.WriteRecord(item); } Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return(View("Index")); }
public ActionResult ViewDetailDay(string MerchantCode) { //Tâm code var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } List <MerchantSummaryDailyTiny> list = new List <MerchantSummaryDailyTiny>(); HttpClient client = new AccessAPI().Access(); HttpResponseMessage response; if (temp.UserType == "A") { response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryForAgentDefaultMerchantCode?AgentCode={0}&&MerchantCode={1}&&ReportDate={2}", temp.UserName, Request.QueryString["MerchantCode"], Request.QueryString["ReportDate"])).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } } if (temp.UserType == "M") { response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryForMerchantCode?MerchantCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } } return(View(list)); }
private List <Models.MerchantSummaryDailyTiny> getAllSumDaily() { var merchantSummary = new List <Models.MerchantSummaryDailyTiny>(); string domain = ""; string url = domain + "/api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryDefault"; HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { merchantSummary = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } return(merchantSummary); }
private List <RETRIVAL_INVALID> getAllRetrivalInvalid() { var RetrivalInvalid = new List <RETRIVAL_INVALID>(); string domain = ""; string url = domain + "api/RETRIVAL_INVALID/GetAllRetrivalInvalid"; HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(url).Result; if (response.IsSuccessStatusCode) { RetrivalInvalid = response.Content.ReadAsAsync <List <RETRIVAL_INVALID> >().Result; } return(RetrivalInvalid); }
// GET: Message public ActionResult Index(int page = 1, int size = 10) { var user = GetUserName(); List <MESSAGE> ListMs = new List <MESSAGE>(); HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MESSAGE/GetMessage?MaCode={0}&UserType={1}", user.UserName, user.UserType)).Result; if (response.IsSuccessStatusCode) { ListMs = response.Content.ReadAsAsync <List <MESSAGE> >().Result; //return RedirectToAction("Index", "Home"); } var ListMessage = ListMs.ToPagedList(page, size); return(View(ListMessage)); }
// GET: Home public ActionResult Index() { //Lay so luong tin nhan chua doc var model = Session[CommonConstants.USER_SESSION]; var user = new USER_INFORMATION(); if (model != null) { user = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MESSAGETYPE/CountUnreadMessage?MaCode={0}&UserType={1}", user.UserName, user.UserType)).Result; if (response.IsSuccessStatusCode) { int number = response.Content.ReadAsAsync <int>().Result; Session.Add(CommonConstants.NUMBER_UNREAD_MESSAGE, number); } return(View()); }
public ActionResult ChangePassword_Action(string currentPassword, string newPassword, string confirmPassword) { if (String.IsNullOrEmpty(currentPassword) || String.IsNullOrEmpty(newPassword) || String.IsNullOrEmpty(confirmPassword) || newPassword != confirmPassword) { TempData["AlertMessage"] = "Vui lòng nhập đầy đủ thông tin!!!"; TempData["AlertType"] = "alert-warning"; return(View("ChangePassword")); //khong nhat thiet phai co model } List <USER_INFORMATION> list = new List <USER_INFORMATION>(); //HttpClient client = new HttpClient(); //client.BaseAddress = new Uri("http://localhost:21212/"); //client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var result = (USER_INFORMATION)Session[CommonConstants.USER_SESSION]; HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/USER_INFORMATION/Change?username={0}&password={1}&newpassword={2}", result.UserName.ToString(), Encryptor.MD5Hash(currentPassword), Encryptor.MD5Hash(newPassword))).Result; if (response.IsSuccessStatusCode) { var check = response.Content.ReadAsAsync <bool>().Result; if (check == true) { TempData["AlertMessage"] = "Đổi mật khẩu thành công !!!"; TempData["AlertType"] = "alert-success"; } else { TempData["AlertMessage"] = "Vui lòng nhập đúng mật khẩu hiện tại!!!"; TempData["AlertType"] = "alert-warning"; } return(View("ChangePassword")); } else { TempData["AlertMessage"] = "Vui lòng nhập đúng mật khẩu hiện tại!!!"; TempData["AlertType"] = "alert-warning"; return(View("Index")); //khong nhat thiet phai co model } }
public ActionResult Edit() { var model = Session[CommonConstants.USER_SESSION]; //khai báo 1 session bên common giống như bên Cart var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/AGENT/FindAgent?agentCode={0}", temp.UserName)).Result; var agent = new AGENT(); if (response.IsSuccessStatusCode) { agent = response.Content.ReadAsAsync <AGENT>().Result; //return RedirectToAction("Index", "Home"); } return(View(agent)); }
public ActionResult FindTransactionDetailInvalidElement(string search, int page = 1, int size = 10) { List <Models.TransInvalidTiny> listTransInvalid = new List <Models.TransInvalidTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (temp.UserType == "T") { if (search == "") { return(RedirectToAction("Index")); } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement?searchString={0}", search)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @TempData["search"] = search; @ViewBag.search = search; } var list = listTransInvalid.ToPagedList(page, size); return(View("Index", list)); } else { if (temp.UserType == "A") { if (search == "") { return(RedirectToAction("Index")); } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Agent?searchString={0}&agentCode={1}", search, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @TempData["search"] = search; @ViewBag.agentCode = temp.UserName; } var list = listTransInvalid.ToPagedList(page, size); return(View("Index", list)); } else { if (search == "") { return(RedirectToAction("Index")); } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Merchant?searchString={0}&merchantCode={1}", search, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @TempData["search"] = search; @ViewBag.search = search; @ViewBag.agentCode = temp.UserName; } var list = listTransInvalid.ToPagedList(page, size); return(View("Index", list)); } } }
public ActionResult Index(string searchString, int page = 1, int size = 10) { List <Models.TransInvalidTiny> transInvalid = new List <Models.TransInvalidTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); int totalPage = 0; int maxPage = 4; int totalTransaction = 0; if (temp.UserType == "T") { HttpResponseMessage responseCountInTrans = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/CountTransInvalid_Master")).Result; if (responseCountInTrans.IsSuccessStatusCode) { totalTransaction = responseCountInTrans.Content.ReadAsAsync <int>().Result; } if (String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/GetTransaction_Detail_Invalid_Master?pageIndex={0}&pageSize={1}", page - 1, size)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; totalPage = (int)Math.Ceiling((double)totalTransaction / size); ViewBag.Total = totalTransaction; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Master?searchString={0}&pageIndex={1}&pageSize={2}", searchString, page - 1, size)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; HttpResponseMessage response2 = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/CountTransInvalidElements_Master?searchString={0}", searchString)).Result; if (response2.IsSuccessStatusCode) { totalTransaction = response2.Content.ReadAsAsync <int>().Result; } totalPage = (int)Math.Ceiling((double)totalTransaction / size); ViewBag.Total = totalTransaction; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } @ViewBag.search = searchString; } } else { if (temp.UserType == "A") { HttpResponseMessage responseCountInTrans = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/CountTransInvalid_Agent?AgentCode={0}", temp.UserName)).Result; if (responseCountInTrans.IsSuccessStatusCode) { totalTransaction = responseCountInTrans.Content.ReadAsAsync <int>().Result; } if (String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/GetTransaction_Detail_Invalid_Agent?AgentCode={0}&pageIndex={1}&pageSize={2}", temp.UserName, page - 1, size)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; totalPage = (int)Math.Ceiling((double)totalTransaction / size); ViewBag.Total = totalTransaction; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Agent?searchString={0}&AgentCode={1}&pageIndex={2}&pageSize={3}", searchString, temp.UserName, page - 1, size)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; HttpResponseMessage response2 = client.GetAsync(string.Format("api/RETRIVAL_INVALID/sp_CountTransInvalidElements_Agent?AgentCode={0}&searchString={1}", temp.UserName, searchString)).Result; if (response2.IsSuccessStatusCode) { totalTransaction = response2.Content.ReadAsAsync <int>().Result; } totalPage = (int)Math.Ceiling((double)totalTransaction / size); ViewBag.Total = totalTransaction; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } @ViewBag.search = searchString; } } else { HttpResponseMessage responseCountInTrans = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/CountTransInvalid_Merchant?MerchantCode={0}", temp.UserName)).Result; if (responseCountInTrans.IsSuccessStatusCode) { totalTransaction = responseCountInTrans.Content.ReadAsAsync <int>().Result; } if (String.IsNullOrEmpty(searchString)) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/GetTransaction_Detail_Invalid_Merchant?MerchantCode={0}&pageIndex={1}&pageSize={2}", temp.UserName, page - 1, size)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; totalPage = (int)Math.Ceiling((double)totalTransaction / size); ViewBag.Total = totalTransaction; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Merchant?searchString={0}&MerchantCode={1}&pageIndex={2}&pageSize={3}", searchString, temp.UserName, page - 1, size)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; HttpResponseMessage response2 = client.GetAsync(string.Format("api/RETRIVAL_INVALID/sp_CountTransInvalidElements_Merchant?MerchantCode={0}&searchString={1}", temp.UserName, searchString)).Result; if (response2.IsSuccessStatusCode) { totalTransaction = response2.Content.ReadAsAsync <int>().Result; } totalPage = (int)Math.Ceiling((double)totalTransaction / size); ViewBag.Total = totalTransaction; ViewBag.Page = page; ViewBag.TotalPage = totalPage; ViewBag.MaxPage = maxPage; ViewBag.First = 1; ViewBag.Last = totalPage; } @ViewBag.search = searchString; } } } return(View(transInvalid.ToList())); }
// GET: Report public ActionResult Index() { string reportType = "Day"; string reportStartDate = "20161101"; // DateTime.Now.ToString("yyyyMM") + "01"; string reportEndDate = "20161130"; //DateTime.Now.ToString("yyyyMMdd"); string reportStartMonth = String.Empty; string reportEndMonth = String.Empty; string reportStartYear = String.Empty; string reportEndYear = String.Empty; string reportStartQuarter = String.Empty; string reportEndQuarter = String.Empty; string reportDataDayFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataGenerality?startDate={0}&endDate={1}"; string reportDateDayForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartGenerality?startDate={0}&endDate={1}"; string reportDataMonthFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataMonthly?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}"; string reportDateMonthForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartMonthly?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}"; string reportDataQuarterFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataQuarterly?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}"; string reportDateQuarterForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartQuarterly?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}"; string reportDataYearFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataYearly?startYear={0}&endYear={1}"; string reportDateYearForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartYearly?startYear={0}&endYear={1}"; string reportDataAPI = String.Format(reportDataDayFormat, reportStartDate, reportEndDate); string reportDateForLineAPI = String.Format(reportDateDayForLineFormat, reportStartDate, reportEndDate); if (HttpContext.Request.HttpMethod == "POST") { reportType = Request["reportType"]; reportStartDate = Request["reportStartDate"]; reportEndDate = Request["reportEndDate"]; reportStartMonth = Request["reportStartMonth"]; reportEndMonth = Request["reportEndMonth"]; reportStartYear = Request["reportStartYear"]; reportEndYear = Request["reportEndYear"]; reportStartQuarter = Request["reportStartQuarter"]; reportEndQuarter = Request["reportEndQuarter"]; switch (reportType.ToLower()) { case "day": reportDataAPI = String.Format(reportDataDayFormat, reportStartDate, reportEndDate); reportDateForLineAPI = String.Format(reportDateDayForLineFormat, reportStartDate, reportEndDate); break; case "month": reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear); reportDateForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear); break; case "quarter": reportDataAPI = String.Format(reportDataQuarterFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear); reportDateForLineAPI = String.Format(reportDateQuarterForLineFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear); break; case "year": reportDataAPI = String.Format(reportDataYearFormat, reportStartYear, reportEndYear); reportDateForLineAPI = String.Format(reportDateYearForLineFormat, reportStartYear, reportEndYear); break; default: break; } } var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } reportDataAPI += ("&code=" + temp.UserName); reportDateForLineAPI += ("&code=" + temp.UserName); List <MERCHANT_SUMMARY> list = new List <MERCHANT_SUMMARY>(); HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(reportDataAPI).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <MERCHANT_SUMMARY> >().Result; } else { return(View("Index")); } response = client.GetAsync(reportDateForLineAPI).Result; List <Models.Statistic> lineChartData = new List <Models.Statistic>(); if (response.IsSuccessStatusCode) { lineChartData = response.Content.ReadAsAsync <List <Models.Statistic> >().Result; } else { return(View("Index")); } HttpResponseMessage responseMerchantType = client.GetAsync(string.Format("api/Merchant_Type/SelectAllMerchantType")).Result; HttpResponseMessage responseCity = client.GetAsync(string.Format("api/Region/FindAllRegion")).Result; if (responseCity.IsSuccessStatusCode && responseMerchantType.IsSuccessStatusCode) { List <MERCHANT_TYPE> lookupType = responseMerchantType.Content.ReadAsAsync <List <MERCHANT_TYPE> >().Result; List <REGION> lookupRegion = responseCity.Content.ReadAsAsync <List <REGION> >().Result; var listMerchantType = getListMerchantType(list); var listRegion = getListRegion(list); var cardTypeReport = getCardTypeReport(list); foreach (var item in listMerchantType) { item.MerchantTypeName = lookupType.FirstOrDefault(a => a.MerchantType == item.MerchantType).Description.ToString(); } foreach (var item in listRegion) { item.RegionName = lookupRegion.FirstOrDefault(a => a.RegionCode == item.RegionCode).RegionName.ToString(); } ViewBag.listRegion = listRegion; ViewBag.listMerchantType = listMerchantType; ViewBag.listSummary = list; ViewBag.cardTypeReport = cardTypeReport; ViewBag.lineChartData = lineChartData; return(View()); } else { return(View("Index")); } }
public ActionResult SendMail(FormCollection form) { var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); var merchant = new MERCHANT(); if (model != null) { temp = (USER_INFORMATION)model; HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT/FindMerchant?merchantCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { merchant = response.Content.ReadAsAsync <MERCHANT>().Result; } } else { return(View("Index")); } var fbMail = new Mail(); fbMail.Subject = form["Subject"]; fbMail.Content = form["Content"]; var Signature = "\n\n-------------\n" + merchant.MerchantName + "\n" + merchant.Owner + "\n" + merchant.Address1 + "\n" + merchant.Email + "\n" + merchant.Phone; fbMail.MailMaster = WebConfigurationManager.AppSettings["toAddress"]; fbMail.MailMerchant = WebConfigurationManager.AppSettings["fromAddress"]; fbMail.Password = WebConfigurationManager.AppSettings["Password"]; var fromAddress = new MailAddress(fbMail.MailMerchant); var toAddress = new MailAddress(fbMail.MailMaster); var smtp = new SmtpClient { Host = WebConfigurationManager.AppSettings["host"], Port = int.Parse(WebConfigurationManager.AppSettings["port"]), EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = true, Credentials = new NetworkCredential(fromAddress.Address, fbMail.Password) }; using (var message = new MailMessage(fromAddress, toAddress) { Subject = fbMail.Subject, Body = fbMail.Content + Signature }) { try { smtp.Send(message); TempData["Message"] = "true"; return(RedirectToAction("Index")); } catch (Exception) { TempData["Message"] = "false"; return(RedirectToAction("Index")); } } }
// // GET: /Chart_Compare/ public ActionResult Index() { string reportType = "month"; string reportStartMonth = "11"; string reportEndMonth = "12"; string reportStartYear = "2016"; string reportEndYear = "2016"; string reportStartQuarter = String.Empty; string reportEndQuarter = String.Empty; string reportDataMonthFormat = String.Empty; string reportDateMonthForLineFormat = String.Empty; string reportDataQuarterFormat = String.Empty; string reportDateQuarterForLineFormat = String.Empty; string reportDataYearFormat = String.Empty; string reportDateYearForLineFormat = String.Empty; string reportDataAPI = String.Empty; string reportMonthForLineAPI = String.Empty; var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (temp.UserType == "T") { reportDataMonthFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataMonthly_Compare?startMonth={0}&startYear={1}"; reportDateMonthForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Compare?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}"; reportDataQuarterFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Quaterly_Compare?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}"; reportDateQuarterForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Quaterly_Compare?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}"; reportDataYearFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Yearly_Compare?startYear={0}&endYear={1}"; reportDateYearForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Yearly_Compare?startYear={0}&endYear={1}"; reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear); reportMonthForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear); } else { if (temp.UserType == "A") { reportDataMonthFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataMonthly_Compare?startMonth={0}&startYear={1}"; reportDateMonthForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Compare_Agent?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}&agentCode={4}"; reportDataQuarterFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Quaterly_Compare_Agent?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}&agentCode={4}"; reportDateQuarterForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Quaterly_Compare_Agent?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}&agentCode={4}"; reportDataYearFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Yearly_Compare_Agent?startYear={0}&endYear={1}&agentCode={2}"; reportDateYearForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Yearly_Compare_Agent?startYear={0}&endYear={1}&agentCode={2}"; reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear); reportMonthForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear, temp.UserName); } else { reportDataMonthFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataMonthly_Compare?startMonth={0}&startYear={1}"; reportDateMonthForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Compare_Merchant?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}&merchantCode={4}"; reportDataQuarterFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Quaterly_Compare_Merchant?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}&merchantCode={4}"; reportDateQuarterForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Quaterly_Compare_Merchant?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}&merchantCode={4}"; reportDataYearFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Yearly_Compare_Merchant?startYear={0}&endYear={1}&merchantCode={2}"; reportDateYearForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportData_Generality_Yearly_Compare_Merchant?startYear={0}&endYear={1}&merchantCode={2}"; reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear); reportMonthForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear, temp.UserName); } } if (HttpContext.Request.HttpMethod == "POST") { reportType = Request["reportType"]; reportStartMonth = Request["reportStartMonth"]; reportEndMonth = Request["reportEndMonth"]; reportStartYear = Request["reportStartYear"]; reportEndYear = Request["reportEndYear"]; reportStartQuarter = Request["reportStartQuarter"]; reportEndQuarter = Request["reportEndQuarter"]; if (temp.UserType == "T") { switch (reportType.ToLower()) { case "month": reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear); reportMonthForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear); //reportMonthForLineAPI1 = String.Format(reportDateMonthForLineFormat, reportEndMonth, reportEndYear); break; case "quarter": reportDataAPI = String.Format(reportDataQuarterFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear); reportMonthForLineAPI = String.Format(reportDateQuarterForLineFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear); break; case "year": reportDataAPI = String.Format(reportDataYearFormat, reportStartYear, reportEndYear); reportMonthForLineAPI = String.Format(reportDateYearForLineFormat, reportStartYear, reportEndYear); break; default: break; } } else { if (temp.UserType == "A") { switch (reportType.ToLower()) { case "month": reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear); reportMonthForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear, temp.UserName); //reportMonthForLineAPI1 = String.Format(reportDateMonthForLineFormat, reportEndMonth, reportEndYear); break; case "quarter": reportDataAPI = String.Format(reportDataQuarterFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear, temp.UserName); reportMonthForLineAPI = String.Format(reportDateQuarterForLineFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear, temp.UserName); break; case "year": reportDataAPI = String.Format(reportDataYearFormat, reportStartYear, reportEndYear, temp.UserName); reportMonthForLineAPI = String.Format(reportDateYearForLineFormat, reportStartYear, reportEndYear, temp.UserName); break; default: break; } } else { switch (reportType.ToLower()) { case "month": reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear); reportMonthForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear, temp.UserName); break; case "quarter": reportDataAPI = String.Format(reportDataQuarterFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear, temp.UserName); reportMonthForLineAPI = String.Format(reportDateQuarterForLineFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear, temp.UserName); break; case "year": reportDataAPI = String.Format(reportDataYearFormat, reportStartYear, reportEndYear, temp.UserName); reportMonthForLineAPI = String.Format(reportDateYearForLineFormat, reportStartYear, reportEndYear, temp.UserName); break; default: break; } } } } HttpResponseMessage response = client.GetAsync(reportMonthForLineAPI).Result; List <Models.Statistic> lineChartData = new List <Models.Statistic>(); if (response.IsSuccessStatusCode) { lineChartData = response.Content.ReadAsAsync <List <Models.Statistic> >().Result; ViewBag.lineChartData = lineChartData; @ViewBag.Month1 = reportStartMonth; @ViewBag.Month2 = reportEndMonth; @ViewBag.Year1 = reportStartYear; @ViewBag.Year2 = reportEndYear; @ViewBag.Quarter1 = reportStartQuarter; @ViewBag.Quarter2 = reportEndQuarter; @ViewBag.startMonth = reportStartMonth + "/" + reportStartYear; @ViewBag.endMonth = reportEndMonth + "/" + reportEndYear; @ViewBag.reportType = reportType.ToLower(); if (reportType.ToLower() == "month") { @ViewBag.ds = tinhTiLe_thang(lineChartData, (int.Parse)(reportStartMonth), (int.Parse)(reportStartYear), (int.Parse)(reportEndMonth), (int.Parse )(reportEndYear)); } else { if (reportType.ToLower() == "year") { @ViewBag.ds = tinhTiLe_nam(lineChartData, (int.Parse)(reportStartYear), (int.Parse )(reportEndYear)); } else { @ViewBag.ds = tinhTiLe_quy(lineChartData, (int.Parse)(reportStartQuarter), (int.Parse)(reportStartYear), (int.Parse)(reportEndQuarter), (int.Parse )(reportEndYear)); } } } else { return(View("Index")); } return(View()); }
public ActionResult ExportPDF(string searchString) { //HttpClient client = new AccessAPI().Access(); string footer = "--footer-right \"Date: [date] [time]\" " + "--footer-center \"Page: [page] of [toPage]\" --footer-line --footer-font-size \"9\" --footer-spacing 5 --footer-font-name \"calibri light\""; List <Models.MerchantSummaryDailyTiny> lists = new List <Models.MerchantSummaryDailyTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } if (temp.UserType == "T") //Master { if (String.IsNullOrEmpty(searchString)) { lists = getAllSumDaily(); @ViewBag.searchString = searchString; } else { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } } else if (temp.UserType == "A") { if (String.IsNullOrEmpty(searchString)) { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryForAgentDefault?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } else { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryForAgentElement?AgentCode={0}&&searchString={1}", temp.UserName, searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } } else { return(View()); } return(new Rotativa.PartialViewAsPdf("MerchantStatistical", lists) { //MerchantSumaryDailyStatistical FileName = "MerchantStatistical.pdf", CustomSwitches = footer }); }
private ActionResult viewReport(string UserCode, string defaultView = "Index") { string reportType = "Day"; string reportStartDate = DateTime.Now.ToString("yyyyMM") + "01"; string reportEndDate = DateTime.Now.ToString("yyyyMMdd"); string reportStartMonth = String.Empty; string reportEndMonth = String.Empty; string reportStartYear = String.Empty; string reportEndYear = String.Empty; string reportStartQuarter = String.Empty; string reportEndQuarter = String.Empty; string reportDataDayFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataGenerality?startDate={0}&endDate={1}"; string reportDateDayForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartGenerality?startDate={0}&endDate={1}"; string reportDataMonthFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataMonthly?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}"; string reportDateMonthForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartMonthly?startMonth={0}&startYear={1}&endMonth={2}&endYear={3}"; string reportDataQuarterFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataQuarterly?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}"; string reportDateQuarterForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartQuarterly?startQuarter={0}&startYear={1}&endQuarter={2}&endYear={3}"; string reportDataYearFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDataYearly?startYear={0}&endYear={1}"; string reportDateYearForLineFormat = "api/MERCHANT_SUMMARY_DAILY/GetReportDateForLineChartYearly?startYear={0}&endYear={1}"; string reportDataAPI = String.Format(reportDataDayFormat, reportStartDate, reportEndDate); string reportDateForLineAPI = String.Format(reportDateDayForLineFormat, reportStartDate, reportEndDate); string userCode = UserCode; ViewBag.UserCode = userCode; handleNullVal(ViewBag.SummaryReport); if (HttpContext.Request.HttpMethod == "POST") { reportType = Request["reportType"]; reportStartDate = Request["reportStartDate"]; reportEndDate = Request["reportEndDate"]; reportStartMonth = Request["reportStartMonth"]; reportEndMonth = Request["reportEndMonth"]; reportStartYear = Request["reportStartYear"]; reportEndYear = Request["reportEndYear"]; reportStartQuarter = Request["reportStartQuarter"]; reportEndQuarter = Request["reportEndQuarter"]; switch (reportType.ToLower()) { case "day": reportDataAPI = String.Format(reportDataDayFormat, reportStartDate, reportEndDate); reportDateForLineAPI = String.Format(reportDateDayForLineFormat, reportStartDate, reportEndDate); break; case "month": reportDataAPI = String.Format(reportDataMonthFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear); reportDateForLineAPI = String.Format(reportDateMonthForLineFormat, reportStartMonth, reportStartYear, reportEndMonth, reportEndYear); break; case "quarter": reportDataAPI = String.Format(reportDataQuarterFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear); reportDateForLineAPI = String.Format(reportDateQuarterForLineFormat, reportStartQuarter, reportStartYear, reportEndQuarter, reportEndYear); break; case "year": reportDataAPI = String.Format(reportDataYearFormat, reportStartYear, reportEndYear); reportDateForLineAPI = String.Format(reportDateYearForLineFormat, reportStartYear, reportEndYear); break; default: break; } } var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } if (!String.IsNullOrEmpty(userCode)) { reportDataAPI += ("&code=" + userCode); reportDateForLineAPI += ("&code=" + userCode); } else { if (temp.UserType != "T") { reportDataAPI += ("&code=" + temp.UserName); reportDateForLineAPI += ("&code=" + temp.UserName); } } List <MERCHANT_SUMMARY> list = new List <MERCHANT_SUMMARY>(); HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(reportDataAPI).Result; if (response.IsSuccessStatusCode) { list = response.Content.ReadAsAsync <List <MERCHANT_SUMMARY> >().Result; } else { return(View(defaultView)); } response = client.GetAsync(reportDateForLineAPI).Result; List <Models.Statistic> lineChartData = new List <Models.Statistic>(); if (response.IsSuccessStatusCode) { lineChartData = response.Content.ReadAsAsync <List <Models.Statistic> >().Result; } else { return(View(defaultView)); } HttpResponseMessage responseMerchantType = client.GetAsync(string.Format("api/Merchant_Type/SelectAllMerchantType")).Result; HttpResponseMessage responseCity = client.GetAsync(string.Format("api/Region/FindAllRegion")).Result; if (responseCity.IsSuccessStatusCode && responseMerchantType.IsSuccessStatusCode) { List <MERCHANT_TYPE> lookupType = responseMerchantType.Content.ReadAsAsync <List <MERCHANT_TYPE> >().Result; List <REGION> lookupRegion = responseCity.Content.ReadAsAsync <List <REGION> >().Result; var listMerchantType = getListMerchantType(list); var listRegion = getListRegion(list); var cardTypeReport = getCardTypeReport(list); foreach (var item in lookupRegion) { var region = listRegion.Find(x => x.RegionCode == item.RegionCode); if (region == null) { listRegion.Add(new MERCHANT_SUMMARY() { RegionName = item.RegionName, NetAmount = 0, TransactionCount = 0, SaleAmount = 0, SaleCount = 0, ReturnCount = 0 }); } else { region.RegionName = item.RegionName; } } foreach (var item in lookupType) { var type = listMerchantType.Find(x => x.MerchantType == item.MerchantType); if (type == null) { listMerchantType.Add(new MERCHANT_SUMMARY() { MerchantTypeName = item.Description, NetAmount = 0, TransactionCount = 0, SaleAmount = 0, SaleCount = 0, ReturnCount = 0 }); } else { type.MerchantTypeName = item.Description; } } ViewBag.SummaryReport = handleNullVal(getCardTypeReport(list).FirstOrDefault()); ViewBag.Regions = listRegion; ViewBag.MerchantTypes = listMerchantType; ViewBag.listRegion = listRegion; ViewBag.listMerchantType = listMerchantType; ViewBag.listSummary = list; ViewBag.cardTypeReport = cardTypeReport; ViewBag.lineChartData = lineChartData; getDataForCharts(); return(View()); } else { return(View(defaultView)); } }
public ActionResult ExportExcel(string searchString) { List <Models.MerchantSummaryDailyTiny> lists = new List <Models.MerchantSummaryDailyTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } if (temp.UserType == "T") //Master { if (String.IsNullOrEmpty(searchString)) { lists = getAllSumDaily(); @ViewBag.searchString = searchString; } else { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } } else if (temp.UserType == "A") { if (String.IsNullOrEmpty(searchString)) { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryForAgentDefault?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } else { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryForAgentElement?AgentCode={0}&&searchString={1}", temp.UserName, searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } } else { return(View()); } var gv = new GridView(); gv.DataSource = lists; gv.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=MERCHANT_SUMMARY_DAILY.xls"); Response.ContentType = "appliation/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); gv.RenderControl(tw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return(View("Index")); }
// GET: Statistical public ActionResult Index(string MerchantType, string RegionType, List <string> MerchantTypeValue, List <string> RegionTypeValue, string searchString, int page = 1, int size = 10) { CheckBoxValue(ref MerchantType, ref MerchantTypeValue); ViewBag.tempMerchantType = MerchantType; CheckBoxValue(ref RegionType, ref RegionTypeValue); ViewBag.tempRegionType = RegionType; List <Models.MerchantSummaryDailyTiny> lists = new List <Models.MerchantSummaryDailyTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } HttpClient client = new AccessAPI().Access(); HttpResponseMessage responseMerchantType = client.GetAsync(string.Format("api/Merchant_Type/SelectAllMerchantType")).Result; HttpResponseMessage responseRegion = client.GetAsync(string.Format("api/REGION/FindAllRegion")).Result; if (responseMerchantType.IsSuccessStatusCode && responseRegion.IsSuccessStatusCode) { List <MERCHANT_TYPE> listMerchantType = responseMerchantType.Content.ReadAsAsync <List <MERCHANT_TYPE> >().Result; List <REGION> listRegion = responseRegion.Content.ReadAsAsync <List <REGION> >().Result; ViewBag.MerchantType = new SelectList(listMerchantType, "MerchantType", "Description"); ViewBag.RegionType = new SelectList(listRegion, "RegionCode", "RegionName"); } if (temp.UserType == "T") //Master { if (String.IsNullOrEmpty(searchString)) { if (MerchantTypeValue == null && RegionTypeValue == null) { var listStatic = getAllSumDaily().ToPagedList(page, size); return(View(listStatic)); } else { string query = queryFilterStatistical(MerchantTypeValue, RegionTypeValue); List <MerchantSummaryDailyTiny> listStatistical = new List <MerchantSummaryDailyTiny>(); HttpResponseMessage responseFilter = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindFilter?query={0}", query)).Result; if (responseFilter.IsSuccessStatusCode) { listStatistical = responseFilter.Content.ReadAsAsync <List <MerchantSummaryDailyTiny> >().Result; } var listStatistical_1 = listStatistical.ToPagedList(page, size); ViewBag.MerchantTypeValue = MerchantTypeValue; ViewBag.RegionTypeValue = RegionTypeValue; return(View(listStatistical_1)); } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } var listStatic = lists.ToPagedList(page, size); @ViewBag.searchString = searchString; return(View(listStatic)); } } else if (temp.UserType == "A") { if (String.IsNullOrEmpty(searchString)) { if (MerchantTypeValue == null && RegionTypeValue == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryForAgentDefault?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } var listStatic = lists.ToPagedList(page, size); @ViewBag.searchString = searchString; return(View(listStatic)); } else { string query = queryFilterStatistical(MerchantTypeValue, RegionTypeValue); query = query + "and AgentCode = '" + temp.UserName + "'"; List <MerchantSummaryDailyTiny> listStatistical = new List <MerchantSummaryDailyTiny>(); HttpResponseMessage responseFilter = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindFilter?query={0}", query)).Result; if (responseFilter.IsSuccessStatusCode) { listStatistical = responseFilter.Content.ReadAsAsync <List <MerchantSummaryDailyTiny> >().Result; } var listStatistical_1 = listStatistical.ToPagedList(page, size); ViewBag.MerchantTypeValue = MerchantTypeValue; ViewBag.RegionTypeValue = RegionTypeValue; return(View(listStatistical_1)); } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryForAgentElement?AgentCode={0}&&searchString={1}", temp.UserName, searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } var listStatic = lists.ToPagedList(page, size); @ViewBag.searchString = searchString; return(View(listStatic)); } } else { return(View()); } }
public ActionResult ExportToCSV(string searchString, int page = 1, int size = 10) { List <Models.TransInvalidTiny> listTransInvalid = new List <Models.TransInvalidTiny>(); string footer = "--footer-right \"Date: [date] [time]\" " + "--footer-center \"Page: [page] of [toPage]\" --footer-line --footer-font-size \"9\" --footer-spacing 5 --footer-font-name \"calibri light\""; var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (temp.UserType == "T") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindAllTransaction_Detail_Invalid")).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } else { if (temp.UserType == "A") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Agent?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Agent?searchString={0}&agentCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } else { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Merchant?MerchantCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Merchant?searchString={0}&merchantCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } } StringWriter sw = new StringWriter(); sw.WriteLine("TransactionCode,ReportDate,MerchantCode,CardtypeCode ,TransactionAmount ,TransactionDate,AccountNumber,TransactionTypeCode,AgentCode,ErrorMessage"); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=Transaction_Detail_Invalid.csv"); Response.ContentType = "text/csv"; var csv = new CsvWriter(sw); foreach (var item in listTransInvalid) { csv.WriteRecord(item); } Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); var list = listTransInvalid.ToPagedList(page, size); return(View("Index", list)); }
public ActionResult ExportToPDF(string searchString) { var listTransInvalid = new List <Models.TransInvalidTiny>(); string footer = "--footer-right \"Date: [date] [time]\" " + "--footer-center \"Page: [page] of [toPage]\" --footer-line --footer-font-size \"9\" --footer-spacing 5 --footer-font-name \"calibri light\""; var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (temp.UserType == "T") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindAllTransaction_Detail_Invalid")).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } else { if (temp.UserType == "A") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Agent?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Agent?searchString={0}&agentCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } else { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Merchant?MerchantCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Merchant?searchString={0}&merchantCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } } return(new Rotativa.PartialViewAsPdf("TransInvalidPDF", listTransInvalid) { //MerchantSumaryDailyStatistical FileName = "Transaction_Detail_Invalid.pdf", CustomSwitches = footer }); }
public ActionResult Index(string searchString, int page = 1, int size = 10) { List <Models.TransInvalidTiny> transInvalid = new List <Models.TransInvalidTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (temp.UserType == "T") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindAllTransaction_Detail_Invalid")).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } else { if (temp.UserType == "A") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Agent?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Agent?searchString={0}&agentCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } // @ViewBag.search = search; } else { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Merchant?MerchantCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Merchant?searchString={0}&merchantCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { transInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } } var listTransInvalid = transInvalid.ToPagedList(page, size); return(View(listTransInvalid)); }
public ActionResult ExportToExcel(string searchString, int page = 1, int size = 10) { List <Models.TransInvalidTiny> listTransInvalid = new List <Models.TransInvalidTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } HttpClient client = new AccessAPI().Access(); if (temp.UserType == "T") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindAllTransaction_Detail_Invalid")).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } } else { if (temp.UserType == "A") { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Agent?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Agent?searchString={0}&agentCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } // @ViewBag.search = search; } else { if (searchString == null) { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalid_Merchant?MerchantCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } } else { HttpResponseMessage response = client.GetAsync(string.Format("api/TRANSACTION_DETAIL_INVALID/FindTransInvalidElement_Merchant?searchString={0}&merchantCode={1}", searchString, temp.UserName)).Result; if (response.IsSuccessStatusCode) { listTransInvalid = response.Content.ReadAsAsync <List <Models.TransInvalidTiny> >().Result; } @ViewBag.search = searchString; } //@ViewBag.search = search; } } var gv = new GridView(); gv.DataSource = listTransInvalid; gv.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename= Transaction_Detail_Invalid.xls"); Response.ContentType = "application/ms-excel"; //Response.Charset = ""; StringWriter sw = new StringWriter(); HtmlTextWriter tw = new HtmlTextWriter(sw); gv.RenderControl(tw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); var list = listTransInvalid.ToPagedList(page, size); return(View("Index", list)); }
public ActionResult ExportCSV(string searchString) { List <Models.MerchantSummaryDailyTiny> lists = new List <Models.MerchantSummaryDailyTiny>(); var model = Session[CommonConstants.USER_SESSION]; var temp = new USER_INFORMATION(); if (model != null) { temp = (USER_INFORMATION)model; } else { return(View()); } if (temp.UserType == "T") //Master { if (String.IsNullOrEmpty(searchString)) { lists = getAllSumDaily(); } else { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryElement?searchString={0}", searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } } else if (temp.UserType == "A") { if (String.IsNullOrEmpty(searchString)) { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/GetMerchantSummaryForAgentDefault?AgentCode={0}", temp.UserName)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } else { HttpClient client = new AccessAPI().Access(); HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT_SUMMARY_DAILY/FindMerchantSummaryForAgentElement?AgentCode={0}&&searchString={1}", temp.UserName, searchString)).Result; if (response.IsSuccessStatusCode) { lists = response.Content.ReadAsAsync <List <Models.MerchantSummaryDailyTiny> >().Result; } @ViewBag.searchString = searchString; } } else { return(View()); } StringWriter sw = new StringWriter(); sw.WriteLine("Merchant Code,Sale Amount,Sale Count,Return Amount,Return Count,Net Amount,Transaction Count,Key Amount,Report Date"); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=MERCHANT_LIST.csv"); Response.ContentType = "text/csv"; //var csv = new CsvWriter(sw); foreach (var item in lists) { sw.WriteLine(String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", item.MerchantCode, item.SaleAmount, item.SaleCount, item.ReturnAmount, item.ReturnCount, item.NetAmount, item.TransactionCount, item.KeyedAmount, item.ReportDate.ToString() )); } Response.Output.Write(sw.ToString()); Response.Flush(); Response.End(); return(View("Index")); }