public Model CreateModel(Model model)
        {
            List <Model> models = _modelRepository.ReadAllModels();

            if (model == null)
            {
                throw new ArgumentException("Model is missing");
            }

            if (models != null)
            {
                foreach (Model m in models)
                {
                    if (model.ModelId == m.ModelId && model.Name == m.Name && model.ManufacturerId == m.ManufacturerId)
                    {
                        throw new InvalidOperationException("Model already exist");
                    }
                }
            }

            if (_modelValidator != null)
            {
                _modelValidator.ValidateModel(model);
            }

            return(_modelRepository.AddModel(model));
        }
Esempio n. 2
0
 public IActionResult AddModel([FromBody] NlpRequest <Model> request)
 {
     return(Ok(_modelrepo.AddModel(request)));
 }
Esempio n. 3
0
 public void AddModel(Model model)
 {
     _modelRepository.AddModel(model);
 }