public ActionResult SearchMassiveEdit(FiltroProductos viewModel) { var productos = GetProductsByFilter(viewModel); foreach (var p in productos) { p.Description = p.Description.Trim(); } return(this.PartialView("_massiveEditList", productos)); }
public virtual JsonResult Export(FiltroProductos viewModel) { var result = GetProductsByFilter(viewModel); string pathName = ConfigurationManager.AppSettings["ExportFilesPath"] + descrFile + ".xlsx"; string serverMapPath = Server.MapPath("~/" + pathName); FileInfo file = new FileInfo(serverMapPath); if (file.Exists) { file.Delete(); file = new FileInfo(serverMapPath); } using (var package = new ExcelPackage(file)) { var ws = package.Workbook.Worksheets.Add(descrFile); var j = 1; var cell = ws.Cells; cell[1, 1].Value = "Producto"; cell[1, 2].Value = "Tipo"; cell[1, 3].Value = "Estado"; cell[1, 4].Value = "Precio Actual"; cell[1, 5].Value = "Presentacion"; cell[1, 6].Value = "Ultima Modificacion"; var i = 2; foreach (var p in result) { j = 1; cell[i, j++].Value = p.Description.Trim(); cell[i, j++].Value = p.TipoProducto.Description; cell[i, j++].Value = p.Estado; cell[i, j++].Value = p.PrecioActual; cell[i, j++].Value = p.Unidad; cell[i, j++].Value = p.Modified.HasValue ? p.Modified.Value.ToShortDateString() : string.Empty; i++; } package.Save(); } return(Json(new { result = serverMapPath, success = true })); }
private IQueryable <Producto> GetProductsByFilter(FiltroProductos viewModel) { var productoes = db.Productoes.Include(p => p.TipoProducto); if (!string.IsNullOrEmpty(viewModel.Descripcion)) { productoes = productoes.Where(_ => _.Description.Contains(viewModel.Descripcion)); } if (viewModel.TipoProducto != null && viewModel.TipoProducto != Guid.Empty) { productoes = productoes.Where(_ => _.TipoProductoId == viewModel.TipoProducto); } return(productoes.OrderBy(_ => _.Description)); }
public ActionResult Search(FiltroProductos viewModel) { var productoes = GetProductsByFilter(viewModel); return(this.PartialView("_list", productoes)); }