public static OfertasModel ToOfertasModel() { NOferta negocio = new NOferta(); OfertasModel ofertas = new OfertasModel(); ofertas.ofertas = new List <OfertaHelper>(); var negocioOfertas = negocio.ToList(); foreach (var item in negocioOfertas) { OfertaHelper oferta = new OfertaHelper(); oferta.CompraMax = item.CompraMax; oferta.CompraMin = item.CompraMin; oferta.Descripcion = item.Descripcion; oferta.FechaDisponibilidad = item.FechaDisponibilidad; oferta.IdOferta = item.IdOferta; oferta.IdUsuario = item.Usuario.IdUsuario; oferta.PorcentajeDescuento = item.PorcentajeDescuento; oferta.Valor = item.Valor; ProductoModel Producto = new ProductoModel(); Producto.Descripcion = item.Producto.Descripcion; Producto.FechaVencimiento = item.Producto.FechaVencimiento; Producto.IdCategoria = item.Producto.Categoria.IdCategoria; Producto.IdEmpresa = item.Producto.Empresa.IdEmpresa; Producto.IdProducto = item.Producto.IdProducto; Producto.Imagen = item.Producto.Imagen; Producto.Marca = item.Producto.Marca; Producto.Modelo = item.Producto.Modelo; Producto.Nombre = item.Producto.Nombre; Producto.PrecioNormal = item.Producto.PrecioNormal; Producto.Stock = item.Producto.Stock; Producto.Temporada = item.Producto.Temporada; oferta.Producto = Producto; ofertas.ofertas.Add(oferta); } return(ofertas); }
public List <OfertaHelper> ToListModel() { List <OfertaHelper> listaOferta = new List <OfertaHelper>(); foreach (var item in Bd.Ofertas.ToList()) { OfertaHelper oferta = new OfertaHelper(); ProductoModel producto = new ProductoModel(); oferta.IdOferta = item.IdOferta; oferta.IdUsuario = item.Usuario.IdUsuario; oferta.PorcentajeDescuento = item.PorcentajeDescuento; oferta.Valor = item.Valor; oferta.CompraMax = item.CompraMax; oferta.CompraMin = item.CompraMin; oferta.Descripcion = item.Descripcion; oferta.FechaDisponibilidad = item.FechaDisponibilidad; //carga producto producto.IdProducto = item.Producto.IdProducto; producto.Descripcion = item.Producto.Descripcion; producto.FechaVencimiento = item.Producto.FechaVencimiento; producto.IdCategoria = item.Producto.Categoria.IdCategoria; producto.IdEmpresa = item.Producto.Empresa.IdEmpresa; producto.Imagen = item.Producto.Imagen; producto.Marca = item.Producto.Marca; producto.Nombre = item.Producto.Nombre; producto.PrecioNormal = item.Producto.PrecioNormal; producto.Stock = item.Producto.Stock; producto.Temporada = item.Producto.Temporada; producto.Modelo = item.Producto.Modelo; oferta.Producto = producto; listaOferta.Add(oferta); } return(listaOferta); }