public void Update(ModelsEntity Models)
        {
            var existing = _models.FindOne(u => u.Id == Models.Id);

            if (existing == null)
            {
                throw new System.Exception("No models found to update");
            }

            _models.UpdateOne(Models);
        }
Beispiel #2
0
        public override async Task <bool> Handle(CreateModelsAggregateCommand command, CancellationToken token)
        {
            _logger.LogInformation("Models aggregate created with name: " + command.name);

            var model = new ModelsEntity(command.name);

            model.setVisibility(Visibility.FromName <Visibility>(command.visibility));
            model.setClassifiction(Classification.FromName <Classification>(command.classification));

            _models.Create(model);

            if (_models.GetById(model.Id) == null)
            {
                _logger.LogInformation("Could not create models entity: " + command.name);
            }

            await Task.CompletedTask;

            return(true);
        }
 public void Create(ModelsEntity entity)
 {
     _models.InsertOne(entity);
     _logger.LogInformation($"Models {entity.Name} inserted in database");
 }