Example #1
0
        public async Task <IActionResult> AdicionarModulo([FromBody] Modulo modulo)
        {
            var claims = (ClaimsIdentity)User.Identity;

            modulo.USUARIO_CRIACAO   = User.Identity.Name;
            modulo.ID_USUARIO_GESTOR = Convert.ToInt32(claims.Claims.ToList().Find(id => id.Type == ClaimTypes.PrimaryGroupSid).Value);
            modulo.DATA_CRIACAO      = DateTime.Now;

            if (!ModelState.IsValid)
            {
                return(UnprocessableEntity());
            }
            await _modulo.Insert(modulo);

            var setorModulo = new SetorModulo
            {
                ID_MODULO       = modulo.ID,
                ID_SETOR        = Convert.ToInt32(claims.Claims.ToList().Find(id => id.Type == ClaimTypes.GroupSid).Value),
                DATA_CRIACAO    = DateTime.Now,
                USUARIO_CRIACAO = User.Identity.Name,
            };
            await _setorModuloRepository.Insert(setorModulo);

            return(Created("/Modulo/Index", modulo));
        }