public ModelBO Create(ModelBO model) { using (var uow = facade.UnitOfWork) { var newModel = uow.ModelRepository.Create(conv.Convert(model)); uow.Complete(); return(conv.Convert(newModel)); } }
//PUT api/values public IHttpActionResult Put(int id, [System.Web.Http.FromBody] ModelBO model) { if (id != model.Id) { return(BadRequest("Path Id does not match Model ID in json object")); } var model1 = facade.ModelService.Update(model); return(Ok(model1)); }
public ModelBO Update(ModelBO model) { using (var uow = facade.UnitOfWork) { var modelFromDb = uow.ModelRepository.Get(model.Id); if (modelFromDb == null) { throw new InvalidOperationException("Model not found"); } modelFromDb.model_name = model.model_name; modelFromDb.model_version = model.model_version; modelFromDb.model_url = model.model_url; uow.Complete(); return(conv.Convert(modelFromDb)); } }
internal Model Convert(ModelBO model) { return(new Model() { Id = model.Id, model_name = model.model_name, model_version = model.model_version, model_author = model.model_author, model_url = model.model_url, model_deployment_environment = model.model_deployment_environment, model_input_features = model.model_input_features, model_dataset_location = model.model_dataset_location, model_code_location = model.model_code_location, model_environment_status = model.model_environment_status, model_artifacts = model.model_artifacts }); }
//public ModelBO Get(int id) //{ // return facade.ModelService.Get(id); //} // POST api/values //public ActionResult<Model> Post([Microsoft.AspNetCore.Mvc.FromBody] ModelBO modelBO) //{ // using (Gabriel_DBEntities entities = new Gabriel_DBEntities()) // { // ModelConverter conv = new ModelConverter(); // var newModel = entities.Model_Catalog. (conv.Convert(modelBO)); // return entities.Model_Catalog.Add(ModelConverter(; // } // POST api/values public ActionResult <ModelBO> Post([System.Web.Http.FromBody] ModelBO model) { return(facade.ModelService.Create(model)); }