예제 #1
0
 public async Task <Response <List <Rol> > > GetAllAsync() =>
 ReturnResult((await CreateMapper()).MapList((await SqlAccessService.SelectData("with recursivo as ( select  SP2.RolId, " +
                                                                                "SP2.PermisoId from Rol_Permiso  SP2  where  " +
                                                                                " sp2.RolId is null  UNION ALL select  sp.RolId," +
                                                                                " sp.PermisoId from Rol_Permiso sp join recursivo r " +
                                                                                "on r.PermisoId= sp.RolId) select * from recursivo r  " +
                                                                                "inner join permiso p on r.PermisoId = p.Id"))));
예제 #2
0
        public async Task <Concurso> Insert(Concurso concurso)
        {
            await SqlAccessService.InsertDataAsync(concurso);

            await new DigitoVerificadorRepository().Validate <ConcursoVerificable>(
                DigitoVerificadorTablasEnum.Concursos);
            return(concurso);
        }
        public new async Task <Response <TraduccionValue> > InsertDataAsync(Idioma idioma, TraduccionValue entity)
        {
            await SqlAccessService.InsertDataAsync(new Parameters()
                                                   .Add("Id_Termino", entity.TerminoId)
                                                   .Add("Id_Idioma", idioma.Id)
                                                   .Add("Traduccion", entity.Traduccion));

            return(Response <TraduccionValue> .Ok(entity));
        }
        public async Task <Response <TraduccionValue> > UpdateDataAsync(TraduccionValue traduccionValue)
        {
            await SqlAccessService.UpdateAsync(new Parameters()
                                               .Add(nameof(TraduccionValue.Traduccion), traduccionValue.Traduccion),
                                               new Parameters()
                                               .Add(nameof(TraduccionValue.Id), traduccionValue.Id));

            return(Response <TraduccionValue> .Ok(traduccionValue));
        }
        public new async Task <Response <List <TraduccionValue> > > Get(List <Idioma> idiomas)
        {
            var result = (await CreateMapper()).MapList(await SqlAccessService.SelectData("SELECT Tr.Id," +
                                                                                          "Tr.Traduccion," +
                                                                                          "T.KeyValue," +
                                                                                          "Tr.Id_Idioma," +
                                                                                          "Tr.Id_Termino " +
                                                                                          "FROM Traducciones AS Tr " +
                                                                                          "INNER JOIN  Terminos T " +
                                                                                          "ON Tr.Id_Termino = T.Id  " +
                                                                                          $"WHERE Tr.Id_Idioma IN ({ string.Join(",", idiomas.Select(x => x.Id))})"));

            return(Response <List <TraduccionValue> > .From(result));
        }
예제 #6
0
        public async Task <Response <Rol> > GetByUsuarioIdAsync(int usuarioId)
        {
            var query = await SqlAccessService.SelectData(" with recursivo as" +
                                                          " (" +
                                                          " select  SP2.RolId, SP2.PermisoId from Rol_Permiso SP2" +
                                                          " join Usuarios ur on ur.Rol_Id = sp2.PermisoId" +
                                                          $" where  sp2.RolId is null and ur.Id = {usuarioId}" +
                                                          " UNION ALL" +
                                                          " select  sp.RolId, sp.PermisoId from Rol_Permiso sp" +
                                                          " join recursivo r on r.PermisoId= sp.RolId" +
                                                          ")" +
                                                          " select * from recursivo r  inner join permiso p on r.PermisoId = p.Id");

            var map = (await CreateMapper()).Map(query);

            return(ReturnResult(map));
        }
예제 #7
0
        public async Task <Response <List <Rol> > > Get()
        {
            var query = await SqlAccessService.SelectData(" with recursivo as" +
                                                          " (" +
                                                          " select  SP2.RolId, SP2.PermisoId from Rol_Permiso SP2" +
                                                          " where  sp2.RolId is null" +
                                                          " UNION ALL" +
                                                          " select  sp.RolId, sp.PermisoId from Rol_Permiso sp" +
                                                          " join recursivo r on r.PermisoId= sp.RolId" +
                                                          ")" +
                                                          " select * from recursivo r  inner join permiso p on r.PermisoId = p.Id" +
                                                          " group by RolId, PermisoId, Id, Nombre, Descripcion, ByDefault,[Type]");

            var map = (await CreateMapper()).MapList(query);

            return(ReturnResult(map));
        }
예제 #8
0
        public new async Task <Response <Rol> > InsertDataAsync(Rol rol)
        {
            await SqlAccessService.InsertDataAsync(rol,
                                                   new Parameters()
                                                   .Add("Type", "Rol"));

            await SqlAccessService.InsertDataAsync(new Parameters()
                                                   .Add("RolId", "NULL")
                                                   .Add("PermisoId", rol.Id),
                                                   "Rol_Permiso");

            foreach (var permission in rol.Permissions)
            {
                await SqlAccessService.InsertDataAsync(new Parameters()
                                                       .Add("RolId", rol.Id)
                                                       .Add("PermisoId", permission.Id),
                                                       "Rol_Permiso");
            }
            return(Response <Rol> .Ok(rol));
        }
예제 #9
0
        public void Crear()
        {
            var sqlService = new SqlAccessService();

            sqlService.Backup();
        }
예제 #10
0
        public void Restore()
        {
            var sqlService = new SqlAccessService();

            sqlService.Restore();
        }
예제 #11
0
 public async Task UpdateLastLoginDate(string email, DateTime date) => await SqlAccessService.UpdateAsync(new Parameters()
                                                                                                          .Add("LastLogin", date),
                                                                                                          new Parameters()
                                                                                                          .Add("Email", email));
        public async Task <Response <List <TraduccionValue> > > GetAllKeys()
        {
            var result = (await CreateMapper()).MapList(await SqlAccessService.SelectData("SELECT Id as Id_Termino, KeyValue FROM Terminos"));

            return(Response <List <TraduccionValue> > .From(result));
        }
예제 #13
0
 public void Insertar(Log log, int userId)
 {
     SqlAccessService.InsertDataAsync(log,
                                      new Parameters()
                                      .Add("Usuario_Id", userId));
 }