示例#1
0
        public async Task <IActionResult> Create([Bind("Database,CNPJ,IE,RazaoSocial,Fantasia,DataAbertura,Email,Website,CEP,Logradouro,Numero,Complemento,Bairro,Cidade,Uf,Unidade,IBGE,GIA,Id,Ativo,DataCadastro,UltimaAtualizacao,Deletado,DeletadoData")] Empresa empresa)
        {
            if (ModelState.IsValid)
            {
                empresa.CNPJ = RemoverCaracteres.StringSemFormatacao(empresa.CNPJ);
                _context.Add(empresa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(empresa));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("SubMenus,Controller,Titulo,MenuId,Id,Ativo,DataCadastro,UltimaAtualizacao,Deletado,DeletadoData")] SubMenu subMenu)
        {
            if (ModelState.IsValid)
            {
                _context.Add(subMenu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MenuId"] = new SelectList(_context.Menu, "Id", "Menus", subMenu.MenuId);
            return(View(subMenu));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Menus,Url,Id,Ativo,DataCadastro,UltimaAtualizacao,Deletado,DeletadoData")] Menu menu)
        {
            if (ModelState.IsValid)
            {
                //verifica duplicidade
                var menuExiste = _menuService.MenuExiste(menu);
                if (menuExiste)
                {
                    ViewData["Message"] = "Menu em duplicidade!";
                    return(View(menu));
                }

                _context.Add(menu);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(menu));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,Name,Age,Username,Password,PerfilImage")] UserViewModel userViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = _mapper.Map <User>(userViewModel);

                if (await saveFileAsync(userViewModel.PerfilImage))
                {
                    _context.Add(user);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    ModelState.AddModelError("PerfilImage", "Arquivo não salvo");
                }
            }
            return(View(userViewModel));
        }