コード例 #1
0
        public ActionResult <Models.Response.AtorResponse> AlterarAtor(int id, Models.Request.AtorRequest req)
        {
            try
            {
                Models.TbAtor atual = atorBusiness.ConsultarAtor(id);

                try
                {
                    Models.TbAtor novo = atorConversor.ToTableConversor(req);

                    atual = atorBusiness.AlterarAtor(atual, novo);

                    Models.Response.AtorResponse resp = atorConversor.ToResponseConversor(atual);

                    return(resp);
                }
                catch (System.Exception e)
                {
                    return(BadRequest(
                               new Models.Response.ErrorResponse(400, e.Message)
                               ));
                }
            }
            catch (System.Exception e)
            {
                return(NotFound(
                           new Models.Response.ErrorResponse(404, e.Message)
                           ));
            }
        }
コード例 #2
0
        public Models.TbAtor ToTableConversor(Models.Request.AtorRequest req)
        {
            Models.TbAtor ator = new Models.TbAtor();
            ator.NmAtor       = req.Ator;
            ator.VlAltura     = req.Altura;
            ator.DtNascimento = req.Nascimento;

            return(ator);
        }
コード例 #3
0
        public Models.TbAtor Converter(Models.Request.AtorRequest atual)
        {
            Models.TbAtor novo = new Models.TbAtor();

            novo.NmAtor       = atual.nome;
            novo.VlAltura     = atual.altura;
            novo.DtNascimento = atual.nascimento;

            return(novo);
        }
コード例 #4
0
ファイル: Ator.cs プロジェクト: PedroSousax3/teste-fullsack
        public ActionResult <Models.Response.AtorResponse> Alterar(int id, Models.Request.AtorRequest ator)
        {
            try
            {
                Models.TbAtor novo = funcaorn.AlterarRN(id, convert.Converter(ator));

                return(convert.Converter(novo));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(
                           new Models.Response.Erro(400, ex.Message)
                           ));
            }
        }
コード例 #5
0
ファイル: Ator.cs プロジェクト: PedroSousax3/teste-fullsack
        public ActionResult <Models.Response.AtorResponse> Inserir(Models.Request.AtorRequest ator)
        {
            try
            {
                Models.TbAtor adicionar = convert.Converter(ator);

                Models.TbAtor novo = funcaorn.InserirRN(adicionar);

                return(convert.Converter(novo));
            }
            catch (System.Exception ex)
            {
                return(BadRequest(
                           new Models.Response.Erro(404, ex.Message)
                           ));
            }
        }
コード例 #6
0
        public ActionResult <Models.Response.AtorResponse> AdicionarAtor(Models.Request.AtorRequest req)
        {
            try
            {
                Models.TbAtor ator = atorConversor.ToTableConversor(req);

                ator = atorBusiness.AdicionarAtor(ator);

                Models.Response.AtorResponse resp = atorConversor.ToResponseConversor(ator);

                return(resp);
            }
            catch (System.Exception e)
            {
                return(BadRequest(
                           new Models.Response.ErrorResponse(400, e.Message)
                           ));
            }
        }