public async Task <ActionResult <List <EnsureLog> > > SyncEnsuresAsync(string userId, List <EnsureSyncModel> changes)
        {
            var addedEnsures = new List <EnsureLog>();

            changes.ForEach(l => {
                if (l.ToAdd)
                {
                    var newl    = new EnsureLog(l.ToSync);                  // renew log ID
                    newl.UserId = userId;
                    addedEnsures.Add(newl);
                    _dbContext.Logs.Add(newl);
                }
                else
                {
                    _dbContext.Logs.Remove(l.ToSync);
                }
            });

            try
            {
                await _dbContext.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                throw;
            }
            return(addedEnsures);
        }
        public async Task <EnsureLog> LogAsync(string userId, EnsureTaste taste)
        {
            var l = new EnsureLog
            {
                UserId      = userId,
                EnsureTaste = taste
            };

            _dbContext.Logs.Add(l);
            await _dbContext.SaveChangesAsync();

            return(l);
        }
 public async Task RemoveLogAsync(EnsureLog log)
 {
     _dbContext.Remove(log);
     await _dbContext.SaveChangesAsync();
 }