Example #1
0
        public async Task <IActionResult> Insert(ProviderInsertViewModel viewmodel)
        {
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <ProviderInsertViewModel, ProviderDTO>();
            });
            IMapper mapper = configuration.CreateMapper();
            // new SERService().GetSERByID(4);
            //Transforma o ClienteInsertViewModel em um ClienteDTO
            ProviderDTO dto = mapper.Map <ProviderDTO>(viewmodel);

            ProviderService svc = new ProviderService();

            try
            {
                await svc.Insert(dto);

                return(RedirectToAction("Index", "Category"));
            }
            catch (Exception ex)
            {
                ViewBag.Erros = ex.Message;
            }
            return(View());
        }