public ActionResult CashLoad() { CashLoadViewModel model = new CashLoadViewModel(); TempData["Chart"] = null; TempData["Sub"] = false; return(View("CashLoad/CashLoad", model)); }
public async Task <ActionResult> CashLoad([Bind(Include = "TerminalId,StartDate,EndDate,Status,Partner,PartnerId,Group,GroupId")] CashLoadViewModel vmodel) { ModelState.Remove("PartnerId"); ModelState.Remove("GroupId"); ModelState.Remove("TerminalId"); if (ModelState.IsValid) { List <CashLoadTableVM> listaux = new List <CashLoadTableVM>(); List <JsonLoadCashChart> listchart = new List <JsonLoadCashChart>(); List <JsonLoadCash> list = new List <JsonLoadCash>(); ApiATM api = new ApiATM(); DateTime?start = DateTime.ParseExact(vmodel.StartDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); DateTime?end = DateTime.ParseExact(vmodel.EndDate, "MM/dd/yyyy", CultureInfo.InvariantCulture); string[] listtn = ListTerminalByGroup(vmodel.GroupId); list = await api.CashLoad(start, end, vmodel.TerminalId, listtn); IEnumerable <dynamic> listTn = repo_terminal.LoadCashList(list, vmodel.Status, vmodel.PartnerId, Convert.ToInt32(Session["partnerId"])); if (listTn.Count() > 0) { foreach (var item in list) { string locationname = ""; foreach (dynamic x in listTn) { if (x.TerminalId == item.TerminalId) { locationname = x.LocationName; break; } } if (locationname != "") { CashLoadTableVM obj = new CashLoadTableVM(item.TerminalId, locationname, item.Date, item.AmountPrevius.ToString(), item.AmountLoad.ToString(), item.AmountCurrent.ToString()); JsonLoadCashChart objchart = new JsonLoadCashChart(item.Date.ToString("yyyy-MM-dd"), item.AmountPrevius, item.AmountLoad); listchart.Add(objchart); listaux.Add(obj); } } } #region Variables Partial TempData["List"] = listaux.Count() > 0 ? Utils.ToDataTable <CashLoadTableVM>(listaux) : null; TempData["filename"] = "CashLoad"; TempData["Chart"] = listchart.Count() > 0 ? JsonConvert.SerializeObject(listchart) : null; TempData["terminal"] = vmodel.TerminalId; TempData["partner"] = vmodel.Partner; TempData["from"] = vmodel.StartDate; TempData["to"] = vmodel.EndDate; TempData["Sub"] = false; #endregion return(View("CashLoad/CashLoad")); } return(RedirectToAction("Index")); }