public string CreateModel(Model model) { try { if (model != null) { var res = _DbContext.Models.Where(x => x.Name == model.Name).FirstOrDefault(); if (res != null) { return("already"); } Database.Model entity = new Database.Model(); entity = AutoMapperConfig.ModelMapper.Map <Database.Model>(model); _DbContext.Models.Add(entity); _DbContext.SaveChanges(); return("created"); } return("null"); } catch (Exception ex) { return(ex.Message); } }
public void CatalogCompare() { Database.Model model1 = GetModel(ConnectionString1); Database.Model model2 = GetModel(ConnectionString2); var comparer = new SqlComparer(); var catalogComparisonResult = comparer.Compare(model1.DefaultServer.DefaultCatalog, model2.DefaultServer.DefaultCatalog, null); }
public bool IsActive(int ModelId) { Database.Model entity = new Database.Model(); if (entity.IsActive) { return(true); } return(false); }
public Models getModel(int ModelId) { Database.Model entity = new Database.Model(); entity = dbcontext.Models.Find(ModelId); var config = new MapperConfiguration(cfg => cfg.CreateMap <Database.Model, Models>()); var mapper = new Mapper(config); Models model = mapper.Map <Models>(entity); return(model); }
public void NavigatorTest() { Database.Model model1 = GetModel(ConnectionString1); Database.Model model2 = GetModel(ConnectionString2); Catalog catalog1 = model1.DefaultServer.DefaultCatalog; Catalog catalog2 = model2.DefaultServer.DefaultCatalog; var result = new SqlComparer().Compare(catalog1, catalog2, null); navigator = new ComparisonResultNavigator(result); CheckCatalog(catalog1, true); CheckCatalog(catalog2, false); }
public string DeleteModel(int ModelId) { Database.Model entity = new Database.Model(); entity = dbcontext.Models.Find(ModelId); if (entity != null) { dbcontext.Models.Remove(entity); dbcontext.SaveChanges(); return("Successfully Deleted"); } return("Done"); }
public void CompareEqualNodes() { Database.Model model1 = GetModel(ConnectionString1); var comparer = new SqlComparer(); comparer.Compare(model1.DefaultServer.DefaultCatalog, model1.DefaultServer.DefaultCatalog, null); var singleResult = comparer.Compare(model1.DefaultServer.DefaultCatalog, model1.DefaultServer.DefaultCatalog, null); foreach (IComparisonResult comparisonResult in singleResult.NestedComparisons) { Assert.IsTrue(comparisonResult.ResultType == ComparisonResultType.Unchanged); } }
public Model GetModel(int id) { Model model; Database.Model entity = _DbContext.Models.Find(id); if (entity != null) { model = AutoMapperConfig.ModelMapper.Map <Model>(entity); } else { model = new Model(); } return(model); }
public string AddModel(Models model) { try { if (model != null) { Database.Model entity = new Database.Model(); var config = new MapperConfiguration(cfg => cfg.CreateMap <Models, Database.Model>()); var mapper = new Mapper(config); entity = mapper.Map <Database.Model>(model); dbcontext.SaveChanges(); return("created"); } return("null"); } catch (Exception ex) { return(ex.Message); } }