public object DeleteMessage(int notificationID) { try { using (SamContext ctx = new SamContext()) { Sam3_Notificacion notificacion = new Sam3_Notificacion(); notificacion = ctx.Sam3_Notificacion.Where(x => x.NotificacionID == notificationID).First(); notificacion.Activo = false; ctx.SaveChanges(); } TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add("Ok"); result.ReturnCode = 200; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } catch (Exception ex) { Logger.Instance.EscribirLog(ex); TransactionalInformation result = new TransactionalInformation(); result.ReturnMessage.Add(ex.Message); result.ReturnCode = 500; result.ReturnStatus = false; result.IsAuthenicated = true; return(result); } }
/// <summary> /// Método para Insertar el mensaje de tipo Notificación obtenido de la cola de mensajes /// a la Base de datos /// </summary> /// <param name="notification">Mensaje tipo Notificacion</param> public static void insertNotification(Notificacion notification) { using (SamContext ctx = new SamContext()) { Sam3_Notificacion noti = new Sam3_Notificacion(); //noti.NotificacionID = notification.NotificacionID; noti.UsuarioIDReceptor = notification.UsuarioIDReceptor; noti.UsuarioIDEmisor = notification.UsuarioIDEmisor; noti.TipoNotificacionID = notification.TipoNotificacionID; noti.Mensaje = notification.Mensaje; noti.FechaEnvio = notification.FechaEnvio; noti.FechaRecepcion = DateTime.Now; //???? noti.EstatusLectura = false; noti.Activo = true; noti.UsuarioModificacion = notification.UsuarioModificacion; noti.FechaModificacion = notification.FechaModificacion; ctx.Sam3_Notificacion.Add(noti); ctx.SaveChanges(); } }