コード例 #1
0
        public async Task <Models.TbQuadro> DeletarQuadroAsync(Models.TbQuadro req)
        {
            ctx.TbQuadro.Remove(req);
            await ctx.SaveChangesAsync();

            return(req);
        }
コード例 #2
0
        public async Task <ActionResult <Models.Response.CadastrarAlterarTimeResponse> > CadastrarTimeAsync(Models.Request.CadastrarAlterarTimeRequest req)
        {
            try
            {
                Models.TbUsuario tbUsuario = await usuarioBsn.ConsultarUsuarioPorIdLoginAsync(req.IdLogin);

                Models.TbQuadro tbQuadro = quadroCnv.ToTbQuadro(req, tbUsuario);

                tbQuadro = await quadroBsn.CadastrarQuadroAsync(tbQuadro);

                Models.TbTime tbTime = timeCnv.ToTbTime(req, tbQuadro);

                tbTime = await timeBsn.CadastrarTimeAsync(tbTime);

                tbTime = await timeBsn.SalvarLinkAsync(tbTime, tbTime);

                Models.TbTimeIntegrante timeIntegrante = timeIntegranteCnv.ToTbIntegrante(tbUsuario.IdUsuario, tbTime.IdTime);

                timeIntegrante = await timeIntegranteBsn.CadastrarTimeIntegranteAsync(timeIntegrante);

                Models.Response.CadastrarAlterarTimeResponse resp = timeCnv.ToTimeResponse(tbTime);

                return(resp);
            }
            catch (Exception e)
            {
                return(BadRequest(
                           new Models.Response.ErroResponse(
                               400, e.Message
                               )
                           ));
            }
        }
コード例 #3
0
        public async Task <ActionResult <Models.Response.LoginResponse> > CadastrarUsuarioAsync(Models.Request.CadastrarUsuarioRequest req)
        {
            try
            {
                esqueciSenhaBsn.ValidarSenhasIdenticas(req.Senha, req.ConfirmarSenha);

                Models.TbLogin tbLogin = usuarioCnv.ToCadastrarTbLogin(req.Email, req.Senha);

                Models.TbUsuario tbUsuario = usuarioCnv.ToCadastrarTbUsuario(req.NomeUsuario, req.NomeCompleto);

                bool ignoreValidation = await usuarioBsn.ValidarCadastroUsuarioLogin(tbUsuario, tbLogin);

                tbLogin = await usuarioBsn.CadastrarLoginAsync(tbLogin);

                tbUsuario = await usuarioBsn.CadastrarUsuarioAsync(tbUsuario);

                tbUsuario = await usuarioBsn.CadastrarUsuarioLoginAsync(tbUsuario, tbLogin.IdLogin);

                Models.TbQuadro tbQuadro = usuarioCnv.ToTbQuadro(tbUsuario.IdUsuario);

                tbQuadro = await quadroBsn.CadastrarQuadroAsync(tbQuadro);

                gerenciadorEmail.EnviarEmailCadastroDeUsuario(tbLogin.DsEmail);

                Models.Response.LoginResponse resp = usuarioCnv.ToLoginResponse(tbLogin, tbUsuario.NmUsuario);

                return(resp);
            }
            catch (Exception e)
            {
                return(BadRequest(
                           new Models.Response.ErroResponse(400, e.Message)
                           ));
            }
        }
コード例 #4
0
        public async Task <ActionResult <Models.Response.CadastrarAlterarTimeResponse> > AlterarTimeAsync(int idTime, Models.Request.CadastrarAlterarTimeRequest req)
        {
            try
            {
                Models.TbTime tbTimeAntigo = await timeBsn.ConsultarTimePorIdTime(idTime);

                Models.TbQuadro tbQuadro = await quadroBsn.ConsultarQuadroPorIdQuadroAsync(tbTimeAntigo.IdQuadro);

                Models.TbTime tbTimeAtual = timeCnv.ToTbTime(req, tbQuadro);

                tbTimeAntigo = await timeBsn.AlterarTimeAsync(tbTimeAntigo, tbTimeAtual);

                Models.Response.CadastrarAlterarTimeResponse resp = timeCnv.ToTimeResponse(tbTimeAntigo);

                return(resp);
            }
            catch (Exception e)
            {
                return(BadRequest(
                           new Models.Response.ErroResponse(
                               400, e.Message
                               )
                           ));
            }
        }
コード例 #5
0
        public async Task <Models.TbQuadro> AlterarQuadroAsync(Models.TbQuadro atual, Models.TbQuadro novo)
        {
            this.ValidarQuadroRequest(novo);

            atual = await quadroDb.AlterarQuadroAsync(atual, novo);

            return(atual);
        }
コード例 #6
0
        public async Task <Models.TbQuadro> AlterarQuadroAsync(Models.TbQuadro atual, Models.TbQuadro novo)
        {
            atual.NmQuadro = novo.NmQuadro;

            await ctx.SaveChangesAsync();

            return(atual);
        }
コード例 #7
0
        public async Task <Models.TbQuadro> CadastrarQuadroAsync(Models.TbQuadro req)
        {
            await ctx.TbQuadro.AddAsync(req);

            await ctx.SaveChangesAsync();

            return(req);
        }
コード例 #8
0
        public Models.TbQuadro ToTbQuadro(Models.Request.CadastrarAlterarQuadroRequest req, Models.TbUsuario tbUsuario)
        {
            Models.TbQuadro resp = new Models.TbQuadro();

            resp.IdUsuario = tbUsuario.IdUsuario;
            resp.NmQuadro  = req.NomeQuadro;

            return(resp);
        }
コード例 #9
0
        public Models.TbQuadro ToTbQuadro(int idUsuario)
        {
            Models.TbQuadro resp = new Models.TbQuadro();

            resp.IdUsuario = idUsuario;
            resp.NmQuadro  = "Meu 1º quadro";

            return(resp);
        }
コード例 #10
0
        public Models.Response.QuadroResponse ToQuadroResponse(Models.TbQuadro req)
        {
            Models.Response.QuadroResponse resp = new Models.Response.QuadroResponse();

            resp.IdQuadro   = req.IdQuadro;
            resp.NomeQuadro = req.NmQuadro;
            resp.Descricao  = "Quadro";

            return(resp);
        }
コード例 #11
0
        private void ValidarQuadroRequest(Models.TbQuadro req)
        {
            if (req.IdUsuario <= 0)
            {
                throw new Exception("Id de usuário inválido.");
            }

            if (req.NmQuadro == string.Empty || req.NmQuadro.Count(x => x != ' ') <= 0)
            {
                throw new Exception("Nome do quadro não pode ser vazio.");
            }
        }
コード例 #12
0
        public async Task <Models.TbQuadro> CadastrarQuadroAsync(Models.TbQuadro req)
        {
            this.ValidarQuadroRequest(req);

            req = await quadroDb.CadastrarQuadroAsync(req);

            if (req.IdQuadro <= 0)
            {
                throw new Exception("Quadro não cadastrado.");
            }

            return(req);
        }
コード例 #13
0
        public async Task <Models.TbQuadro> ConsultarQuadroPorIdQuadroAsync(int idQuadro)
        {
            if (idQuadro < 0)
            {
                throw new Exception("Id do quadro inválido.");
            }

            Models.TbQuadro resp = await quadroDb.ConsultarQuadroPorIdQuadroAsync(idQuadro);

            this.ValidarQuadroRequest(resp);

            return(resp);
        }
コード例 #14
0
 public async Task <Models.TbQuadro> DeletarQuadroAsync(Models.TbQuadro req)
 {
     return(await quadroDb.DeletarQuadroAsync(req));
 }
コード例 #15
0
        public Models.TbTime ToTbTime(Models.Request.CadastrarAlterarTimeRequest req, Models.TbQuadro tbQuadro)
        {
            Models.TbTime resp = new Models.TbTime();

            resp.NmTime   = req.NomeTime;
            resp.DsTime   = req.DescricaoTime;
            resp.IdQuadro = tbQuadro.IdQuadro;

            return(resp);
        }