Example #1
0
        public BackEnd.Controllers.Response.VacinacaoResponse AgendarVacina(BackEnd.Controllers.Request.VacinacaoRequest request)
        {
            Models.TbVacinacao tbVacina = new Models.TbVacinacao();

            tbVacina.IdCliente     = request.IdCliente;
            tbVacina.IdPet         = request.IdPet;
            tbVacina.DsLocal       = request.Local;
            tbVacina.DsObservacoes = request.Observacoes;
            tbVacina.DsVacina      = request.Vacina;
            tbVacina.DtVacinacao   = request.Data;

            ctx.TbVacinacao.Add(tbVacina);
            ctx.SaveChanges();

            BackEnd.Controllers.Response.VacinacaoResponse response = new BackEnd.Controllers.Response.VacinacaoResponse();

            response.IdCliente   = request.IdCliente;
            response.IdPet       = request.IdPet;
            response.Local       = request.Local;
            response.Observacoes = request.Observacoes;
            response.Vacina      = request.Vacina;
            response.Data        = request.Data;

            return(response);
        }
        public BackEnd.Controllers.Response.VacinacaoResponse AgendarVacina(BackEnd.Controllers.Request.VacinacaoRequest request)
        {
            Database.AgendamentoVacinaDatabase database = new Database.AgendamentoVacinaDatabase();

            if (string.IsNullOrEmpty(request.Local))
            {
                throw new Exception("Ocorreu um erro com o Local");
            }

            if (string.IsNullOrEmpty(request.Vacina))
            {
                throw new Exception("Ocorreu um erro com a Vacina");
            }

            BackEnd.Controllers.Response.VacinacaoResponse response = database.AgendarVacina(request);

            return(response);
        }
        public ActionResult <BackEnd.Controllers.Response.VacinacaoResponse> agendarVacina(BackEnd.Controllers.Request.VacinacaoRequest request)
        {
            try
            {
                Business.AgendamentoVacinaBusiness business = new Business.AgendamentoVacinaBusiness();

                BackEnd.Controllers.Response.VacinacaoResponse response = business.AgendarVacina(request);

                return(response);
            }
            catch (System.Exception ex)
            {
                return(new BadRequestObjectResult(
                           new BackEnd.Controllers.Response.ErroResponse(ex, 400)
                           ));
            }
        }