示例#1
0
 public IEnumerable <NoteDto> GetAll()
 {
     using (var context = new NotesDatabaseContext(ConnectionStringProvider.EntityDatabaseConnectionString))
     {
         return(context.Notes.ToList().Select(i => i.Map <NoteDto>()).ToList());
     }
 }
示例#2
0
 public NoteDto Get(int id)
 {
     using (var context = new NotesDatabaseContext(ConnectionStringProvider.EntityDatabaseConnectionString))
     {
         return(context.Notes.Single(n => n.Id == id).Map <NoteDto>());
     }
 }
示例#3
0
        public void Post(NoteDto noteDto)
        {
            using (var context = new NotesDatabaseContext(ConnectionStringProvider.EntityDatabaseConnectionString))
            {
                var dataItem = noteDto.Map <Data.Models.Note>();

                context.Notes.Add(dataItem);
                context.SaveChanges();
            }
        }