public async Task <IActionResult> InsertAsync(DiscountStockFormViewModel viewModel) { if (ModelState.IsValid) { viewModel.DiscountStock.InsertDate = DateTime.Now; viewModel.DiscountStock.RegisterEmployeeId = _employeeLogin.GetEmployee().Id; //viewModel.DiscountStock.Active = true; await _discountStock.InsertAsync(viewModel.DiscountStock); foreach (var item in viewModel.ProductsList) { await _discountProductStock.InsertAsync(new Models.ManyToMany.DiscountProductStock { DiscountProductId = viewModel.DiscountStock.Id, StockId = item }); } TempData["MSG_S"] = Message.MSG_S_002; return(RedirectToAction(nameof(Index))); } ICollection <Stock> List = await _stockRepository.FindAllsAsync(_employeeLogin.GetEmployee().BusinessId); ViewBag.Product = List.Select(x => new SelectListItem(x.Product.Name, x.ProductId.ToString())); return(View(viewModel)); }
public async Task <FileResult> DownloadReport(string search, DateTime?start, DateTime?end) { DateTime startDate = start ?? DateTime.Now.AddDays(-30); DateTime endDate = end ?? DateTime.Now; string path = ExcelGenerator.FileExcel.GerarArquivo <Stock>(new ExcelConfigurations(), (List <Stock>) await _stockRepository.FindAllsAsync(search, startDate, endDate, _employeeLogin.GetEmployee().BusinessId)); string contentType = "application/xlsx"; string hostServidor = HttpContext.Request.Host.Host; path = Path.Combine(hostServidor, path); return(File(path, contentType, "Stock.xlsx")); }