public async Task <ActionResult> ImportSales(ImportSalesViewModel model) { AlertMessage alert = new AlertMessage(); model = null; if (TempData["ImportSales"] != null) { model = TempData["ImportSales"] as ImportSalesViewModel; } else { alert.Text = StaticMessage.ERR_INVALID_INPUT; } if (model != null) { HierSalesBusiness business = new HierSalesBusiness(new SmtpService()); business.SetUserAuth(ViewBag.UserAuth); alert = await business.ImportSales(model); } TempData["AlertMessage"] = alert; return(RedirectToAction("Index")); }
public ActionResult PreviewImportSales(ImportSalesViewModel model) { AlertMessage alert = new AlertMessage(); if (!ModelState.IsValid) { alert.Text = string.Join(System.Environment.NewLine, ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); } else { HierSalesBusiness business = new HierSalesBusiness(); business.SetUserAuth(ViewBag.UserAuth); alert = business.Preview(model); } TempData["AlertMessage"] = alert; if (alert.Data != null) { TempData["ImportSales"] = alert.Data; return(View(alert.Data)); } else { return(RedirectToAction("Import")); } }
public ActionResult Index() { HierSalesBusiness business = new HierSalesBusiness(); business.SetUserAuth(ViewBag.UserAuth); ViewBag.IsEditable = business.IsEditable(); return(View()); }
public ActionResult ExportSales(JDatatableViewModel model) { HierSalesBusiness business = new HierSalesBusiness(); business.SetUserAuth(ViewBag.UserAuth); AlertMessage alert = business.ExportSalesToExcel(model); if (alert.Status == 1) { var bytes = alert.Data as byte[]; return(File(bytes, System.Net.Mime.MediaTypeNames.Application.Octet, string.Format("HirarkiSales-{0}.xlsx", DateTime.UtcNow.ToUtcID().ToString("yyyyMMdd-HHmm")))); } return(RedirectToAction("Index")); }
public ActionResult DatatableRayon(RayonDatatableViewModel model) { if (!Request.IsAjaxRequest()) { return(RedirectToAction("Index")); } JDatatableResponse resp = new JDatatableResponse(); HierSalesBusiness business = new HierSalesBusiness(); business.SetUserAuth(ViewBag.UserAuth); resp = business.GetDatatableCustomer(model); return(new MyJsonResult(resp, JsonRequestBehavior.AllowGet)); }
public ActionResult ImportSales() { HierSalesBusiness business = new HierSalesBusiness(); business.SetUserAuth(ViewBag.UserAuth); if (!business.IsEditable()) { TempData["AlertMessage"] = new AlertMessage(StaticMessage.ERR_ACCESS_DENIED); return(RedirectToAction("Index")); } List <HierSalesViewModel> model = null; if (TempData["_Data"] != null) { model = TempData["_Data"] as List <HierSalesViewModel>; } return(View(model)); }