public List <string> ListarLibro(int condominio)
        {
            try
            {
                SigescoEntities bd         = new SigescoEntities();
                var             listaLibro = (from a in bd.LIBRO_SUCESOS
                                              where a.ID_CONDOMINIO == condominio
                                              orderby a.FECHA_SUCESO descending
                                              select a).Take(100).ToList();

                List <string>        lista  = new List <string>();
                List <LIBRO_SUCESOS> _lista = listaLibro;
                int x = _lista.Count();
                for (int i = 0; i < x; i++)
                {
                    LIBRO_SUCESOS obj = new LIBRO_SUCESOS();
                    obj = _lista[i];
                    string fecha = Convert.ToDateTime(obj.FECHA_SUCESO).ToString("dddd dd, MMMM, yyyy");
                    string fila  = fecha + "|" + obj.REFERENCIA + "|" + obj.DETALLES;
                    lista.Add(fila);
                }

                return(lista);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public bool GrabarLibro(LIBRO_SUCESOS nuevo)
 {
     try
     {
         SigescoEntities bd = new SigescoEntities();
         using (bd)
         {
             var listaLibro = (from a in bd.LIBRO_SUCESOS
                               orderby a.ID_SUCESO descending
                               select a.ID_SUCESO).FirstOrDefault();
             nuevo.ID_SUCESO = listaLibro + 1;
             bd.LIBRO_SUCESOS.Add(nuevo);
             bd.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemple #3
0
        public JsonResult GrabarLibro(FormCollection collection)
        {
            AnunciosDAL   bd    = new AnunciosDAL();
            LIBRO_SUCESOS libro = new LIBRO_SUCESOS();

            libro.ID_CONDOMINIO = int.Parse(collection["Condominio"].ToString());
            libro.REFERENCIA    = (collection["Persona"].ToString() + " - " + collection["Perfil"].ToString());
            libro.DETALLES      = collection["Cuerpo"].ToString();
            libro.FECHA_SUCESO  = DateTime.Now;
            var model = bd.GrabarLibro(libro);

            if (model != null)
            {
                var result = new { Success = true, Message = "Succes Message", model };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var result = new { Success = false, Message = "Error Message" };
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }