Exemplo n.º 1
0
        public async Task <HabitEntry> UpdateEntry(HabitEntry entry)
        {
            var entity = await _db.HabitEntries.Where(z => z.Id == entry.Id).SingleAsync();

            entity.Notes = entry.Notes;
            await _db.SaveChangesAsync();

            return(entity.ToDomain());
        }
Exemplo n.º 2
0
 public async Task <HabitEntry> SaveHabitEntry(HabitEntry entry)
 {
     if (!await _habits.EntryExists(entry.Id))
     {
         return(await _habits.InsertEntry(entry));
     }
     else
     {
         return(await _habits.UpdateEntry(entry));
     }
 }
Exemplo n.º 3
0
        public async Task <HabitEntry> InsertEntry(HabitEntry entry)
        {
            var entity = new Context.HabitEntry
            {
                Id      = entry.Id,
                Notes   = entry.Notes,
                Created = entry.Created,
                HabitId = entry.HabitId
            };
            await _db.HabitEntries.AddAsync(entity);

            await _db.SaveChangesAsync();

            return(entity.ToDomain());
        }