Esempio n. 1
0
        public string Get(int id)
        {
            //MaterialApoyo nuevo = new MaterialApoyo("", "", "", "", 1, 1);
            string query = "Select * from materialapoyo\n" +
                           "where idmateria = " + id + ";";
            Conexion             conn = new Conexion();
            List <Generico2>     lst1 = conn.metodo_consulta(query, 8);
            List <MaterialApoyo> lst  = new List <MaterialApoyo>();

            for (int i = 0; i < lst1.Count; i++)
            {
                MaterialApoyo nuevo = new MaterialApoyo(
                    Convert.ToInt32(lst1[i].Lst[0].Parametro.ToString()),
                    lst1[i].Lst[1].Parametro.ToString(),
                    lst1[i].Lst[2].Parametro.ToString(),
                    lst1[i].Lst[3].Parametro.ToString(),
                    lst1[i].Lst[5].Parametro.ToString(),
                    Convert.ToInt32(lst1[i].Lst[6].Parametro.ToString()),
                    Convert.ToInt32(lst1[i].Lst[7].Parametro.ToString())
                    );
                lst.Add(nuevo);
            }

            return(JsonConvert.SerializeObject(lst));
        }
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Create(MaterialApoyo MaterialApoyo)
        {
            if (!ModelState.IsValid)
            {
                InicializarMensaje(null);
                return(View(MaterialApoyo));
            }
            Response response = new Response();

            try
            {
                response = await apiServicio.InsertarAsync(MaterialApoyo,
                                                           new Uri(WebApp.BaseAddress),
                                                           "api/MaterialesDeApoyo/InsertarMaterialesDeApoyo");

                if (response.IsSuccess)
                {
                    var responseLog = await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                    {
                        ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                        ExceptionTrace       = null,
                        Message              = "Se ha creado un material apoyo",
                        UserName             = "******",
                        LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                        LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                        EntityID             = string.Format("{0} {1}", "Material Apoyo:", MaterialApoyo.IdMaterialApoyo),
                    });

                    return(RedirectToAction("Index"));
                }

                ViewData["Error"] = response.Message;

                ViewData["IdFormularioDevengacion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <FormularioDevengacion>(new Uri(WebApp.BaseAddress), "api/FormulariosDevengacion/ListarFormulariosDevengacion"), "IdFormularioDevengacion", "ModoSocial");

                return(View(MaterialApoyo));
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Creando material de apoyo",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Create),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
Esempio n. 3
0
        public async Task <Response> PostMaterialApoyo([FromBody] MaterialApoyo MaterialApoyo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var respuesta = Existe(MaterialApoyo);
                if (!respuesta.IsSuccess)
                {
                    db.MaterialApoyo.Add(MaterialApoyo);
                    await db.SaveChangesAsync();

                    return(new Response
                    {
                        IsSuccess = true,
                        Message = Mensaje.Satisfactorio
                    });
                }

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                    ExceptionTrace       = ex.Message,
                    Message              = Mensaje.Excepcion,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "",
                });

                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Error,
                });
            }
        }
        public async void ingresarProlipa()
        {
            bool    conexion = this.HayInternet();
            string  usuario  = this.usuario.Text;
            string  password = this.password.Text;
            Usuario login    = new Usuario();

            if (conexion == true)
            {
                idusuario = await login.login(usuario, password);

                Console.WriteLine("Id del Usuario = " + idusuario);
                if (idusuario == null || idusuario == "")
                {
                    error error = new error();
                    error.Show();
                    ingresar.Click += ingresar_Click;
                }
                else
                {
                    success success = new success();
                    success.Show();
                    this.login.Hide();
                    this.descarga.Show();
                    Libros libro = new Libros();
                    listaL = await libro.buscarlibros(idusuario);

                    Libros();
                    Cuadernos cuaderno = new Cuadernos();
                    listaC = await cuaderno.buscarcuadernos(idusuario);

                    Guias guias = new Guias();
                    listaG = await guias.buscarguias(idusuario);

                    PlanLector planLector = new PlanLector();
                    listaP = await planLector.buscarplanlector(idusuario);

                    MaterialApoyo material = new MaterialApoyo();
                    listaM = await material.buscarmaterial(idusuario);

                    Planificaciones planificacion = new Planificaciones();
                    listaPl = await planificacion.buscarplanificaciones(idusuario);

                    crearbaseregion(idusuario);
                }
            }
            else
            {
                MessageBox.Show("No tiene una conexion a internet", "Mensaje informativo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public int Post(MaterialApoyo entrada)
        {
            DateTime currentTime  = DateTime.Now;
            String   hora         = (TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Central Standard Time")).ToString("HH:mm:ss");
            string   fecha_actual = (TimeZoneInfo.ConvertTimeBySystemTimeZoneId(currentTime, TimeZoneInfo.Local.Id, "Central Standard Time")).ToString();
            int      cod          = 0;

            try
            {
                Conexion        conn = new Conexion();
                List <Generico> lst  = new List <Generico>
                {
                    new Generico("titulo", entrada.Titulo, 2),
                    new Generico("fecha", fecha_actual, 3),
                    new Generico("enlace", entrada.Enlace, 2),
                    new Generico("descripcion", entrada.Descripcion, 2),
                    new Generico("registro", entrada.Id_maestro, 1),
                    new Generico("idmateria", entrada.Id_materia, 1)
                };
                cod = conn.Post("MaterialApoyoInsert", lst);
            }
            catch
            {
                return(-1);
            }
            try
            {
                Conexion        conn = new Conexion();
                List <Generico> lst  = new List <Generico>
                {
                    new Generico("titulo", entrada.Titulo, 2),
                    new Generico("texto", entrada.Descripcion, 2),
                    new Generico("fecha", fecha_actual, 3),
                    new Generico("registro", entrada.Id_maestro, 1),
                    new Generico("idtipo", 3, 1)
                };
                lst.Add(new Generico("idcalificacion", 1, 5));
                lst.Add(new Generico("idexamen", 1, 5));
                lst.Add(new Generico("idactividad", 1, 5));
                lst.Add(new Generico("idmaterialapoyo", cod, 1));

                conn.metodo_proc("PublicacionInsert", lst);
                return(cod);
            }
            catch
            {
                return(-1);
            }
        }
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(string id, MaterialApoyo MaterialApoyo)
        {
            Response response = new Response();

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    response = await apiServicio.EditarAsync(id, MaterialApoyo, new Uri(WebApp.BaseAddress),
                                                             "api/MaterialesDeApoyo");

                    if (response.IsSuccess)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                            EntityID             = string.Format("{0} : {1}", "Material de apoyo", id),
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ADV),
                            Message  = "Se ha actualizado un material de apoyo",
                            UserName = "******"
                        });

                        return(RedirectToAction("Index"));
                    }
                    ViewData["Error"] = response.Message;

                    ViewData["IdFormularioDevengacion"] = new Microsoft.AspNetCore.Mvc.Rendering.SelectList(await apiServicio.Listar <FormularioDevengacion>(new Uri(WebApp.BaseAddress), "api/FormulariosDevengacion/ListarFormulariosDevengacion"), "IdFormularioDevengacion", "ModoSocial");

                    return(View(MaterialApoyo));
                }
                return(BadRequest());
            }
            catch (Exception ex)
            {
                await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                {
                    ApplicationName      = Convert.ToString(Aplicacion.WebAppTh),
                    Message              = "Editando una material de apoyo",
                    ExceptionTrace       = ex.Message,
                    LogCategoryParametre = Convert.ToString(LogCategoryParameter.Edit),
                    LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                    UserName             = "******"
                });

                return(BadRequest());
            }
        }
        private Response Existe(MaterialApoyo MaterialApoyo)
        {
            var bdd = MaterialApoyo.NombreDocumento;
            var MaterialApoyorespuesta = db.MaterialApoyo.Where(p => p.NombreDocumento == bdd).FirstOrDefault();

            if (MaterialApoyorespuesta != null)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.ExisteRegistro,
                    Resultado = null,
                });
            }

            return(new Response
            {
                IsSuccess = false,
                Resultado = MaterialApoyorespuesta,
            });
        }
Esempio n. 8
0
        private Response Existe(MaterialApoyo MaterialApoyo)
        {
            var bdd  = MaterialApoyo.NombreDocumento;
            var bdd1 = MaterialApoyo.Ubicacion;
            var bd2  = MaterialApoyo.IdFormularioDevengacion;
            var MaterialApoyorespuesta = db.MaterialApoyo.Where(p => p.NombreDocumento == bdd && p.Ubicacion == bdd1 && p.IdFormularioDevengacion == bd2).FirstOrDefault();

            if (MaterialApoyorespuesta != null)
            {
                return(new Response
                {
                    IsSuccess = true,
                    Message = Mensaje.ExisteRegistro,
                    Resultado = null,
                });
            }

            return(new Response
            {
                IsSuccess = false,
                Resultado = MaterialApoyorespuesta,
            });
        }
Esempio n. 9
0
        public async Task <Response> PutMaterialApoyo([FromRoute] int id, [FromBody] MaterialApoyo MaterialApoyo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ModeloInvalido
                    });
                }

                var existe = Existe(MaterialApoyo);
                if (existe.IsSuccess)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = Mensaje.ExisteRegistro,
                    });
                }

                var MaterialApoyoActualizar = await db.MaterialApoyo.Where(x => x.IdMaterialApoyo == id).FirstOrDefaultAsync();

                if (MaterialApoyoActualizar != null)
                {
                    try
                    {
                        MaterialApoyoActualizar.NombreDocumento         = MaterialApoyo.NombreDocumento;
                        MaterialApoyoActualizar.Ubicacion               = MaterialApoyo.Ubicacion;
                        MaterialApoyoActualizar.IdFormularioDevengacion = MaterialApoyo.IdFormularioDevengacion;
                        await db.SaveChangesAsync();

                        return(new Response
                        {
                            IsSuccess = true,
                            Message = Mensaje.Satisfactorio,
                        });
                    }
                    catch (Exception ex)
                    {
                        await GuardarLogService.SaveLogEntry(new LogEntryTranfer
                        {
                            ApplicationName      = Convert.ToString(Aplicacion.SwTH),
                            ExceptionTrace       = ex.Message,
                            Message              = Mensaje.Excepcion,
                            LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical),
                            LogLevelShortName    = Convert.ToString(LogLevelParameter.ERR),
                            UserName             = "",
                        });

                        return(new Response
                        {
                            IsSuccess = false,
                            Message = Mensaje.Error,
                        });
                    }
                }



                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.ExisteRegistro
                });
            }
            catch (Exception)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = Mensaje.Excepcion
                });
            }
        }