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) )); } }
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); }
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) )); } }
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) )); } }
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) )); } }