コード例 #1
0
        public ResponseDTO LoginUser(UserDTO userDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            try
            {
                using (db_PruebaEntities db_PruebaEntities = new db_PruebaEntities())
                {
                    var getuser = db_PruebaEntities.SP_LOGIN_USER(userDTO.Rut, userDTO.Pass).ToList();
                    if (getuser.Count() > 0)
                    {
                        responseDTO.code    = 0;
                        responseDTO.message = "OK";
                    }
                    else
                    {
                        responseDTO.code    = 998;
                        responseDTO.message = "Usuario No encontrado";
                    }
                }
            }
            catch (Exception ex)
            {
                responseDTO.code    = 999;
                responseDTO.message = String.Concat("Se cayo la wea", ex.Message.ToString());
            }
            return(responseDTO);
        }
コード例 #2
0
        public ResponseDTO InsertUser(UserDTO userDTO)
        {
            ResponseDTO responseDTO = new ResponseDTO();

            try
            {
                using (db_PruebaEntities db_PruebaEntities = new db_PruebaEntities())
                {
                    var getuser = db_PruebaEntities.SP_INSERT_USER(userDTO.Name, userDTO.Rol, userDTO.Pass, userDTO.Email, userDTO.Rut);
                    if (getuser == 1)
                    {
                        responseDTO.code    = 0;
                        responseDTO.message = "OK";
                    }
                    else
                    {
                        responseDTO.code    = 998;
                        responseDTO.message = "A ocurrido un error al intentar ingresar el Usuario";
                    }
                }
            }
            catch (Exception ex)
            {
                responseDTO.code    = 999;
                responseDTO.message = String.Concat("Se cayo la wea", ex.Message.ToString());
            }
            return(responseDTO);
        }
コード例 #3
0
        public UserDTO GetUser(decimal idUser)
        {
            UserDTO userDTO = new UserDTO();

            try
            {
                using (db_PruebaEntities db_PruebaEntities = new db_PruebaEntities())
                {
                    var getuser = db_PruebaEntities.SP_GET_USER(idUser).ToList();
                    if (getuser.Count() > 0)
                    {
                        var Datauser = getuser.FirstOrDefault();
                        userDTO = new UserDTO()
                        {
                            Iduser = Datauser.ID_USUARIO,
                            Email  = Datauser.EMAIL,
                            Name   = Datauser.NOMBRE,
                            Pass   = Datauser.CONTRASENA,
                            Rol    = Datauser.ROL,
                            Rut    = Datauser.RUT
                        };
                        userDTO.code    = 0;
                        userDTO.message = "OK";
                    }
                    else
                    {
                        userDTO.code    = 998;
                        userDTO.message = "Usuario No encontrado";
                    }
                }
            }
            catch (Exception ex)
            {
                userDTO.code    = 999;
                userDTO.message = String.Concat("Se cayo la wea", ex.Message.ToString());
            }
            return(userDTO);
        }