public static bool CrearAlerta(string email, string comentarios, double longitud, double latitude) { try { EcolectModelDataContext ecolectEntities = new EcolectModelDataContext(); Alerta nuevaAlerta = new Alerta { email = email, comentarios = comentarios, longitud = longitud, latitud = latitude, estado = 0 }; ecolectEntities.Alertas.InsertOnSubmit(nuevaAlerta); ecolectEntities.SubmitChanges(); return true; } catch (Exception ex) { return false; } }
public static bool EliminarAlertas(int idAlerta) { try { EcolectModelDataContext ecolectEntities = new EcolectModelDataContext(); var alerta = ecolectEntities.Alertas.Where(cmp => cmp.idAlerta == idAlerta).FirstOrDefault(); ecolectEntities.Alertas.DeleteOnSubmit(alerta); ecolectEntities.SubmitChanges(); return true; } catch (Exception ex) { return false; } }
public static bool CambiarEstado(int idAlerta) { try { EcolectModelDataContext ecolectEntities = new EcolectModelDataContext(); var alerta = ecolectEntities.Alertas.Where(cmp => cmp.idAlerta == idAlerta).FirstOrDefault(); if (alerta.estado == 1) { alerta.estado = 0; } else if (alerta.estado == 0) { alerta.estado = 1; } ecolectEntities.SubmitChanges(); return true; } catch (Exception ex) { return false; } }