예제 #1
0
        //
        // GET: /Plantilla/
        public ActionResult Index()
        {
            var service = new PlantillasServices.PlantillasClient();

            var dtos = service.ListaPlantillas();

            Mapper.CreateMap<PlantillaDto, PlantillaViewModel>();
            var model = Mapper.Map<List<PlantillaViewModel>>(dtos);

            return View(model);
        }
        //
        // GET: /Programacion/Create
        public ActionResult Create()
        {
            var service = new PlantillasServices.PlantillasClient();
            var plantillasDtos = service.ListaPlantillas();

            //Mapper.CreateMap<PlantillaDto, PlantillaViewModel>();
            //var model = Mapper.Map<List<PlantillaViewModel>>(plantillasDtos);
            ViewData["PlantillaId"] = new SelectList(
                plantillasDtos.Select(x => new { value = x.Id, text = x.Descripcion }),
                "value", "text");

            return View();
        }
        //
        // GET: /Programacion/Edit/5
        public ActionResult Edit(int id)
        {
            //Invocamos al servicio
            var service = new ProgramacionServices.ProgramacionClient();

            //Como código de empleado le pasamos el current user id (es importante que coincida con el empleado id)
            var programacionDto = service.ObtenerProgramacion(id);

            //Mapeamos el DTO a nuestro modelo (de forma automática o a mano, dependiendo de nuestra necesidad)
            var model = Mapper.Map<ProgramacionViewModel>(programacionDto);

            var service1 = new PlantillasServices.PlantillasClient();
            var plantillasDtos = service1.ListaPlantillas();

            //Mapper.CreateMap<PlantillaDto, PlantillaViewModel>();
            //var model = Mapper.Map<List<PlantillaViewModel>>(plantillasDtos);
            ViewData["PlantillaId"] = new SelectList(
                plantillasDtos.Select(x => new { value = x.Id, text = x.Descripcion }),
                "value", "text", programacionDto.PlantillaId);

            return View(model);
        }