/// <summary> /// Inserta una nueva notificacion en la tabla /// </summary> /// <param name="notif"></param> public long InsertNotification(NotificacionModel notif) { long idNotificacion = 0; using (var entity = new NoscDBEntities()) { var res = (from o in entity.Notificacions where o.IdNotificacion == notif.IdNotificacion select o).FirstOrDefault(); //insertar elemento ya que no existe if (res == null) { idNotificacion = new UNID().getNewUNID(); try { entity.Notificacions.AddObject(new Notificacion() { IdNotificacion = idNotificacion, Titulo = notif.Titulo, Mensaje = notif.Mensaje, Parametro = notif.Parametro, IdApp = notif.IdApp, IdUsuario = notif.IdUsuario, FechaCreacion = new UNID().getNewUNID(), FechaNotificacion = notif.FechaNotificacion, IsCerrado = notif.IsCerrado, CanCerrar = notif.CanCerrar, IsModified = false, LastModifiedDate = new UNID().getNewUNID(), Recurrencia = 30, FechaUltimaMuestra = new UNID().getNewUNID(), IsNotificacionActiva = true, IsDescartarOnClick = false }); entity.SaveChanges(); UpdateSync("Notificacion", entity); } catch (Exception) { return 0; } } } return idNotificacion; }
public string GetModifiedData() { string res = ""; try { using (var entity = new NoscDBEntities()) { res = entity.SP_TABLE_JSON_MODIFIEDDATA("MODIFIEDDATA").First<string>(); } } catch (Exception ex) { res = ex.Message; } return res; }
public string GetSpUpsertServerRows(string json, string tableName) { try { using (var entity = new NoscDBEntities()) { string ids = entity.SpUpsertServerRows(json, tableName).First<string>(); return ids; } } catch (Exception) { throw; } }
private string GetSerealizeJson(List<string> deserialize, string nombreTable) { string resultJson = null; try { using (NoscDBEntities entity = new NoscDBEntities()) { entity.CommandTimeout = 1147483647; string query = this.GetExecStoreProcedure(deserialize.First(), deserialize.Last(), nombreTable); switch (nombreTable) { case "APP_USUARIO": var result = entity.ExecuteStoreQuery<Model.SynClases.APP_USUARIO>(query, null).ToList(); if (result.Count > 0) resultJson = SerializerJson.SerializeParametros(result); break; case "CAT_APP": var result1 = entity.ExecuteStoreQuery<Model.SynClases.CAT_APP>(query, null).ToList(); if (result1.Count > 0) resultJson = SerializerJson.SerializeParametros(result1); break; case "Notificacion": var result2 = entity.ExecuteStoreQuery<Model.SynClases.Notificacion>(query, null).ToList(); if (result2.Count() > 0) resultJson = SerializerJson.SerializeParametros(result2); break; } } } catch (Exception ex) { resultJson = ex.Message; } return resultJson; }
/// <summary> /// Desactiva Notificaciones (IsNotificacionActiva) /// </summary> /// <param name="notif"></param> public string UpdateNotification(NotificacionModel notif) { string response =null; using (var entity = new NoscDBEntities()) { try { var res = (from o in entity.Notificacions where o.IdNotificacion == notif.IdNotificacion select o).FirstOrDefault(); //actualiza el elemento dependiendo el parametro if (res != null) { res.IsNotificacionActiva = notif.IsNotificacionActiva; res.LastModifiedDate = new UNID().getNewUNID(); entity.SaveChanges(); response = "Exito"; UpdateSync("Notificacion", entity); } } catch (Exception ex) { return ex.Message; } } return response; }