Ejemplo n.º 1
0
        public async Task <ActionResult> Cadastrar()
        {
            List <FornecedorDTO> fornecedores = await fsvc.GetFornecedores();

            List <CategoriaDTO> categorias = await csvc.GetCategorias();

            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <FornecedorDTO, FornecedorQueryViewModel>();
                cfg.CreateMap <CategoriaDTO, CategoriaQueryViewModel>();
            });

            IMapper mapper = configuration.CreateMapper();
            // new SERService().GetSERByID(4);
            //Transforma o ClienteInsertViewModel em um ClienteDTO

            //Este objeto "dados" é uma lista de objetos ViewModel
            List <FornecedorQueryViewModel> dadosFornecedores = mapper.Map <List <FornecedorQueryViewModel> >(fornecedores);
            List <CategoriaQueryViewModel>  dadosCategorias   = mapper.Map <List <CategoriaQueryViewModel> >(categorias);

            ViewBag.Fornecedores = dadosFornecedores;
            ViewBag.Categorias   = dadosCategorias;

            return(View());
        }
Ejemplo n.º 2
0
 protected void CargarCategorias()
 {
     foreach (Categoria x in CatService.GetCategorias("Productos"))
     {
         ddlCategoria.Items.Add(new ListItem(x.Descripcion, x.Id.ToString()));
     }
 }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        mProductos  = mProductoService.GetProductos();
        mCategorias = mCategoriaService.GetCategorias("Productos");

        if (!IsPostBack)
        {
            if (Request.QueryString["Buscar"] != null)
            {
                FiltrarBusqueda(Request.QueryString["Buscar"].ToString());
            }

            CargarCategorias();
            CargarMarcas();
            CargarProductos();
        }
    }
Ejemplo n.º 4
0
        // GET: Categoria
        public async Task <ActionResult> Index()
        {
            CategoriaService    svc        = new CategoriaService();
            List <CategoriaDTO> categorias = await svc.GetCategorias();

            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <CategoriaDTO, CategoriaQueryViewModel>();
            });
            IMapper mapper = configuration.CreateMapper();
            // new SERService().GetSERByID(4);
            //Transforma o ClienteInsertViewModel em um ClienteDTO
            List <CategoriaQueryViewModel> categoriasViewModel =
                mapper.Map <List <CategoriaQueryViewModel> >(categorias);

            ViewBag.Categorias = categoriasViewModel;

            return(View());
        }