Beispiel #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)
                           ));
            }
        }
Beispiel #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);
        }
        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);
        }
Beispiel #4
0
        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)
                           ));
            }
        }
Beispiel #5
0
        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)
                           ));
            }
        }
Beispiel #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)
                           ));
            }
        }