public VoidCommandResponse Handle(SetDefaulMessagesCommand command)
        {
            context.Set <MessageDbModel>().Where(model => model.AccountId == command.AccountId).Delete();

            var messagesToCopy = context.Set <MessageDbModel>()
                                 .Where(model => model.AccountId == null && command.GroupSettingsId == model.MessageGroupId)
                                 .ToList()
                                 .Select(model => new MessageDbModel
            {
                ImportancyFactor = model.ImportancyFactor,
                AccountId        = command.AccountId,
                StartTime        = model.StartTime,
                EndTime          = model.EndTime,
                IsEmergencyText  = model.IsEmergencyText,
                IsStopped        = model.IsStopped,
                Message          = model.Message,
                MessageRegime    = model.MessageRegime,
                OrderNumber      = model.OrderNumber
            }).ToList();

            context.BulkInsert(messagesToCopy);

            var userToConnect = context.Set <AccountDbModel>().FirstOrDefault(model => model.Id == command.AccountId && !model.IsDeleted);

            userToConnect.GroupSettingsId = command.GroupSettingsId;

            context.Set <AccountDbModel>().AddOrUpdate(userToConnect);

            context.SaveChanges();

            return(new VoidCommandResponse());
        }
        public VoidCommandResponse Handle(SaveSpyFunctionsCommand command)
        {
            context.SpyFunctions.Where(model => model.SpyId == command.SpyId).Delete();

            if (command.Functions == null || !command.Functions.Any())
            {
                context.SaveChanges();
                return(new VoidCommandResponse());
            }

            context.BulkInsert(command.Functions.Select(functionId => new SpyFunctionDbModel
            {
                FunctionId = functionId,
                SpyId      = command.SpyId
            }));

            context.SaveChanges();

            return(new VoidCommandResponse());
        }