예제 #1
0
 public UserRole GetById(Guid id)
 {
     using (var connection = context.CreateConnection())
     {
         return(connection.Query <UserRole>(UserRoleQuery.ById(id)).SingleOrDefault());
     }
 }
예제 #2
0
 public void Delete(Guid id)
 {
     using (var connection = context.CreateConnection())
     {
         connection.Execute(UserRoleQuery.Delete(id));
     }
 }
예제 #3
0
 public IEnumerable <UserRole> GetAll()
 {
     using (var connection = context.CreateConnection())
     {
         return(connection.Query <UserRole>(UserRoleQuery.All()));
     }
 }
예제 #4
0
        internal static bool ConsultarRol()
        {
            const string methodName = "ConsultarRol";

            try
            {
                Log.WriteEntry(ClassName, methodName, TraceEventType.Information, "Consultando Rol de usuario: " + _userName);

                // Leer User Role
                var URquery = new UserRoleQuery(_userName);
                var result  = _proxy.Handle(URquery);

                Log.WriteEntry(ClassName, methodName, TraceEventType.Information, string.Format("Resultado: UserID: {0} Nombre: {1} Rol: {2}", result.UserID, result.UserName, result.UserRole));

                // Guardar UserId para Lectura de datos
                _userID   = result.UserID;
                _userRole = result.UserRole;
                return(true);
            }
            catch (Exception ex)
            {
                Log.WriteEntry(ClassName, methodName, TraceEventType.Error, string.Format("Error: {0}", ex.Message));
                return(false);
            }
        }
예제 #5
0
        static bool LoginAdministrador(IMessageHandling proxy)
        {
            var loginCmd = new LoginCommand
            {
                UserName = "******",
                Password = "******",
            };

            var status = proxy.Handle(loginCmd);

            bool Success = status.GetType() == typeof(Success);

            if (Success)
            {
                Console.WriteLine("Login Aceptado.");

                // Leer User Role
                var URquery = new UserRoleQuery(loginCmd.UserName);

                var result = proxy.Handle(URquery);
                Console.WriteLine(string.Format(" UserID: {0} Nombre: {1} Rol: {2}", result.UserID, result.UserName, result.UserRole));
                // Guardar UserId para Lectura de datos
                _userID = result.UserID;

                return(true);
            }
            else
            {
                Console.WriteLine(string.Format("Login Denegado. Mensaje: {0}", (status as Failure).Errormessage));
                return(false);
            }
        }
예제 #6
0
 public UserRole Update(UserRole userrole)
 {
     using (var connection = context.CreateConnection())
     {
         connection.Execute(UserRoleQuery.Update(userrole));
         return(userrole);
     }
 }
예제 #7
0
        // Query Handling

        public UserRoleQueryResult Handle(UserRoleQuery query)
        {
            ICollectionRead <Usuario> qryDataUser     = new UsuarioData();
            IEntityRead <Userinfo>    qryDataUserInfo = new UserinfoData();
            UserRoleQueryHandler      qryHandler      = new UserRoleQueryHandler(qryDataUser, qryDataUserInfo);

            return(qryHandler.Handle(query));
        }
예제 #8
0
        public UserRole Create(UserRole userrole)
        {
            if (userrole.Id == Guid.Empty)
            {
                userrole.Id = Guid.NewGuid();
            }

            using (var connection = context.CreateConnection())
            {
                connection.Execute(UserRoleQuery.Insert(userrole));
                return(userrole);
            }
        }
예제 #9
0
        public void In_UserRoleQuery(UserRoleQuery query)
        {
            try
            {
                ICollectionRead <Usuario> qryDataUser     = new UsuarioData();
                IEntityRead <Userinfo>    qryDataUserInfo = new UserinfoData();
                UserRoleQueryHandler      qryHandler      = new UserRoleQueryHandler(qryDataUser, qryDataUserInfo);

                Out_UserRoleQuery(qryHandler.Handle(query));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #10
0
        static bool LoginJefeGrupo(IMessageHandling proxy)
        {
            var loginCmd = new LoginCommand
            {
                UserName = "******",
                Password = "******",
            };

            var status = proxy.Handle(loginCmd);

            bool Success = status.GetType() == typeof(Success);

            if (Success)
            {
                Console.WriteLine("Login Aceptado.");

                // Leer User Role
                var URquery = new UserRoleQuery(loginCmd.UserName);

                var result = proxy.Handle(URquery);
                Console.WriteLine(string.Format(" UserID: {0} Nombre: {1} Rol: {2}", result.UserID, result.UserName, result.UserRole));

                // Guardar UserId para Lectura de datos
                _userID = result.UserID;

                // Valor de prueba en DB 72011518751
                Console.WriteLine(string.Format(" Comparacion UserID leído: {0}  esperado: 72011518751 ", _userID));


                return(true);
            }
            else
            {
                Console.WriteLine(string.Format("Login Denegado. Mensaje: {0}", (status as Failure).Errormessage));
                return(false);
            }
        }
예제 #11
0
 public UserRoleQueryResult Handle(UserRoleQuery query)
 {
     return(GetUserRole(query.Login));
 }
예제 #12
0
        public async Task <IActionResult> Get([FromQuery] UserRoleQuery query)
        {
            var result = await _mediator.Send(query);

            return(Ok(result));
        }