public async Task <ChanpropsRecord> Create(ChanpropsRecord model)
        {
            var tracking = peerChatDb.ChangeTracker.QueryTrackingBehavior;

            peerChatDb.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;

            var existingRecord = await Lookup(new ChanpropsLookup { channelmask = model.channelmask });

            var record = existingRecord.FirstOrDefault();

            model.setAt = DateTime.UtcNow;
            if (record == null)
            {
                var entry = await peerChatDb.AddAsync <ChanpropsRecord>(model);

                var num_modified = await peerChatDb.SaveChangesAsync();

                peerChatDb.ChangeTracker.QueryTrackingBehavior = tracking;
                await ResyncChanPropsForChanMask(model.channelmask, model.kickExisting ?? false);

                return(entry.Entity);
            }
            else
            {
                model.Id = record.Id;
                var entry = peerChatDb.Update <ChanpropsRecord>(model);
                await peerChatDb.SaveChangesAsync();

                peerChatDb.ChangeTracker.QueryTrackingBehavior = tracking;
                await ResyncChanPropsForChanMask(model.channelmask, model.kickExisting ?? false);


                return(entry.Entity);
            }
        }
        public Task <bool> Delete(UsermodeLookup lookup)
        {
            return(Task.Run(async() =>
            {
                var total_modified = 0;
                var usermodes = (await Lookup(lookup)).ToList();
                foreach (var usermode in usermodes)
                {
                    if (usermode.Id < 0)
                    {
                        total_modified++;
                        DeleteTemporaryUsermode(usermode.Id);
                    }
                    else
                    {
                        peerChatDb.Remove <UsermodeRecord>(usermode);
                        total_modified += await peerChatDb.SaveChangesAsync();
                    }

                    await ResyncChannelUsermodes(usermode.channelmask);
                }

                SendBansUpdate(usermodes, false);
                return usermodes.Count > 0 && total_modified > 0;
            }));
        }
 public Task <bool> Delete(GlobalOpersLookup lookup)
 {
     return(Task.Run(async() =>
     {
         var users = (await Lookup(lookup)).ToList();
         foreach (var user in users)
         {
             peerChatDb.Remove <GlobalOpersRecord>(user);
         }
         var num_modified = await peerChatDb.SaveChangesAsync();
         return users.Count > 0 && num_modified > 0;
     }));
 }