Exemplo n.º 1
0
        public ActionResult <BackEnd.Controllers.Response.LoginResponse> Login(BackEnd.Controllers.Request.LoginRequest request)
        {
            Business.LoginBusiness Business = new Business.LoginBusiness();

            try
            {
                BackEnd.Controllers.Response.LoginResponse response = Business.login(request);
                return(response);
            }
            catch (System.Exception ex)
            {
                return(new BadRequestObjectResult(
                           new BackEnd.Controllers.Response.ErroResponse(ex, 400)
                           ));
            }
        }
Exemplo n.º 2
0
        public BackEnd.Controllers.Response.LoginResponse login(BackEnd.Controllers.Request.LoginRequest request)
        {
            Database.LoginDatabase logando = new Database.LoginDatabase();

            if (string.IsNullOrEmpty(request.email))
            {
                throw new Exception("Email Inválido");
            }

            if (string.IsNullOrEmpty(request.senha))
            {
                throw new Exception("Senha Inválida");
            }

            BackEnd.Controllers.Response.LoginResponse response = logando.logar(request);

            return(response);
        }
Exemplo n.º 3
0
        public BackEnd.Controllers.Response.LoginResponse logar(BackEnd.Controllers.Request.LoginRequest Request)
        {
            Models.veterinarioContext ctx = new Models.veterinarioContext();

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

            if (Request.email == "*****@*****.**")
            {
                Models.TbFuncionario LoginFunc = ctx.TbFuncionario
                                                 .FirstOrDefault(x => x.IdLoginNavigation.DsEmail == Request.email && x.IdLoginNavigation.DsSenha == Request.senha);

                response.email       = LoginFunc.DsEmailpessoal;
                response.IdCliente   = LoginFunc.IdFuncionario;
                response.NomeCliente = LoginFunc.NmFuncionario;

                return(response);
            }

            else
            {
                Models.TbCliente Login = ctx.TbCliente.Include(x => x.IdLoginNavigation)
                                         .FirstOrDefault(x => x.IdLoginNavigation.DsEmail == Request.email && x.IdLoginNavigation.DsSenha == Request.senha);

                List <Models.TbPet> pets = ctx.TbPet.Where(x => x.IdClienteNavigation.IdCliente == Login.IdCliente).ToList();


                response.IdCliente   = Login.IdCliente;
                response.IdLogin     = Login.IdLogin;
                response.email       = Login.DsEmail;
                response.NomeCliente = Login.NmCliente;
                response.tbPet       = pets.Select(x => new BackEnd.Controllers.Response.PetsResponse {
                    idPet   = x.IdPet,
                    nomePet = x.NmPet,
                    tipoPet = x.TpPet
                }).ToList();

                return(response);
            }
        }