public static int RememberNote(Activity activity , string nameNote , string entry , string tag = "" , ITurnContext <IMessageActivity> turnContext = null) { if (activity != null) { try { var db = new SqlUserRepository(); var user = db.GetAll().FirstOrDefault(x => x.UserId == activity.From.Id && x.UserName == activity.From.Name && x.ChannelId == activity.ChannelId); if (user != null) { var dbNotes = new SqlNoteRepository(); dbNotes.Add(new Note(user, nameNote, entry, tag)); return(dbNotes.Save()); } } catch (Exception ex) { if (turnContext != null) { turnContext.SendActivityAsync(MessageFactory.Text(ex.Message)); } Console.WriteLine(ex); } } return(0); }
public static Note GetNoteById(int id) { var db = new SqlNoteRepository(); return(db.GetById(id)); }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { //NoteRepository = new XmlNoteRepository(); NoteRepository = new SqlNoteRepository(); NoteRepository.Add("Test", "Post"); }