public ActionResult TipoPremios() { result = null; try { var model = _uwork.TipoPremioRepository.Transform(x => new { TipoPremio = x.tipo }); ExcelManagement.ListToExcel(model, Response); } catch (Exception ex) { Logger.LogException(ex); TempData["err"] = "No se pudo visualizar la vista"; result = RedirectToAction("Error", "ErrorManagement"); } return(result); }
public ActionResult Usuarios() { result = null; try { var model = _uwork.UsuarioRepository.Transform(x => new { NombreUsuario = $"{x.nombre} {x.apellido}", Email = x.email, Rol = x.Role.nombre }); ExcelManagement.ListToExcel(model, Response); } catch (Exception ex) { Logger.LogException(ex); TempData["err"] = "No se pudo visualizar la vista"; result = RedirectToAction("Error", "ErrorManagement"); } return(result); }
public IActionResult CreateExcel() { var predicate = PredicateBuilder.True <Order>(); predicate = predicate.And(x => x.Deleted == false); var model = orderRepository.GetAll(predicate); var list = model.Select(x => new { Factura_Nº = x.Id, Cliente = x.Person.Name + " " + x.Person.LastName, Fecha = x.CreatedDate.ToString("dd/MM/yyyy"), Total = x.Amount, }).ToList(); var fileName = $"test.xlsx"; var mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; byte[] fileBytes = ExcelManagement.ListToExcel(list); return(File(fileBytes, mimeType, fileName)); }
public ActionResult Medicion() { result = null; try { var model = _uwork.MedicionRepository.Transform(x => new { NombreUsuario = $"{x.Usuario.nombre} {x.Usuario.apellido}", ValorPremio = x.Premio.valor, NombrePremio = x.Premio.nombre, RangoInicio = x.Rango1.Inicio, RangoFin = x.Rango1.Fin, UsuarioModificador = $"{x.Usuario1.nombre} {x.Usuario1.apellido}" }); ExcelManagement.ListToExcel(model, Response); } catch (Exception ex) { Logger.LogException(ex); TempData["err"] = "No se pudo visualizar la vista"; result = RedirectToAction("Error", "ErrorManagement"); } return(result); }