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 ) )); } }
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 ) )); } }
public Models.Response.CadastrarAlterarTimeResponse ToTimeResponse(Models.TbTime req) { Models.Response.CadastrarAlterarTimeResponse resp = new Models.Response.CadastrarAlterarTimeResponse(); resp.IdTime = req.IdTime; resp.NomeTime = req.NmTime; resp.Descricao = req.DsTime; return(resp); }
public Models.Response.ConsultarTimesResponse ToTimesReponse(List <Models.TbTime> req) { Models.Response.ConsultarTimesResponse resp = new Models.Response.ConsultarTimesResponse(); List <Models.Response.CadastrarAlterarTimeResponse> times = new List <Models.Response.CadastrarAlterarTimeResponse>(); foreach (Models.TbTime time in req) { Models.Response.CadastrarAlterarTimeResponse x = new Models.Response.CadastrarAlterarTimeResponse(); x.IdTime = time.IdTime; x.NomeTime = time.NmTime; x.Descricao = "Time"; times.Add(x); } resp.Times = times; return(resp); }
public async Task <ActionResult <Models.Response.CadastrarAlterarTimeResponse> > ConsultarTimePorIdQuadroAsync(int idTime) { try { Models.TbTime tbTime = await timeBsn.ConsultarTimePorIdTime(idTime); if (tbTime == null) { return(NotFound()); } Models.Response.CadastrarAlterarTimeResponse resp = timeCnv.ToTimeResponse(tbTime); return(resp); } catch (Exception e) { return(BadRequest( new Models.Response.ErroResponse( 400, e.Message ) )); } }