private static Notification CreateNotification(ScientificProduction sp, Profile researcher) { Notification n = new Notification(); n.username = researcher.Username; n.type = sp.Type; n.title = sp.Title; return(n); }
private static Microsoft.Data.Sqlite.SqliteCommand ConstructInsertCommand(ScientificProduction sp, int researcherId) { var command = Program.SqlConn.CreateCommand(); command.CommandText = @" insert into scientific_productions (ResearcherId, Type, Title, Content) values ($researcherId, $type, $title, $content) "; command.Parameters.AddWithValue("$researcherId", researcherId); command.Parameters.AddWithValue("$type", sp.Type); command.Parameters.AddWithValue("$title", sp.Title); command.Parameters.AddWithValue("$content", sp.Content); return(command); }
private List <ScientificProduction> ReadProductions(SqliteCommand command) { List <ScientificProduction> productions = new List <ScientificProduction>(); ScientificProduction sc; using (var reader = command.ExecuteReader()) { while (reader.Read()) { sc = new ScientificProduction( reader.GetString(2), reader.GetString(3), reader.GetString(4) ); productions.Add(sc); } } return(productions); }
public string PublishScientificProductionAndNotify(ScientificProduction sp, Profile researcher) { try { InsertScientificProductionQuery(sp, researcher.Id); List <int> Ids = GetIDsOfResearchersInField(researcher.Id, researcher.Field); Notification notification = CreateNotification(sp, researcher); foreach (int id in Ids) { Notify(notification, id); } return("done"); } catch (Exception ex) { return(ex.Message); } }
private static void InsertScientificProductionQuery(ScientificProduction sp, int researcherId) { Microsoft.Data.Sqlite.SqliteCommand command = ConstructInsertCommand(sp, researcherId); command.ExecuteNonQuery(); }