public void Cannot_Delete_Catalog_With_Note_Associated() { // Arrange var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note" }; var savedCatalog = CatalogRepository.Add(catalog); var note = new HmmNote { Subject = "Testing subject", Content = "Testing content", CreateDate = DateTime.Now, LastModifiedDate = DateTime.Now, Author = _author, Catalog = savedCatalog }; NoteRepository.Add(note); // Act var result = CatalogRepository.Delete(catalog); // Assert Assert.False(result, "Error: deleted catalog with note attached to it"); Assert.False(CatalogRepository.ProcessMessage.Success); Assert.Single(CatalogRepository.ProcessMessage.MessageList); }
public void Cannot_Delete_NonExists_Catalog_From_DataSource() { // Arrange var catalog = new NoteCatalog { Name = "GasLog", Render = _render, Schema = "TestSchema", IsDefault = true, Description = "testing note" }; CatalogRepository.Add(catalog); var catalog2 = new NoteCatalog { Name = "GasLog2", Render = _render, Schema = "TestSchema", IsDefault = false, Description = "testing note" }; // Act var result = CatalogRepository.Delete(catalog2); // Assert Assert.False(result); Assert.False(CatalogRepository.ProcessMessage.Success); Assert.Single(CatalogRepository.ProcessMessage.MessageList); }
public static async Task <int> Delete(Catalog catalog) { if (catalog == null) { throw new ArgumentNullException(nameof(catalog)); } if (string.IsNullOrWhiteSpace(catalog.Id)) { throw new Exception("目录ID不能为空"); } using (DbHelper db = new DbHelper()) { return(await CatalogRepository.Delete(db, catalog)); } }
public void Dispose() { if (_dbContext is DbContext context) { context.Reset(); } var systems = LookupRepo.GetEntities <Subsystem>().ToList(); foreach (var sys in systems) { SubsystemRepository.Delete(sys); } var notes = LookupRepo.GetEntities <HmmNote>().ToList(); foreach (var note in notes) { NoteRepository.Delete(note); } var catalogs = LookupRepo.GetEntities <NoteCatalog>().ToList(); foreach (var catalog in catalogs) { CatalogRepository.Delete(catalog); } var renders = LookupRepo.GetEntities <NoteRender>().ToList(); foreach (var render in renders) { RenderRepository.Delete(render); } var authors = LookupRepo.GetEntities <Author>().ToList(); foreach (var author in authors) { AuthorRepository.Delete(author); } if (_dbContext is DbContext newContext) { newContext.Reset(); } GC.SuppressFinalize(this); }
public void DeleteCatalog(Model.Local.Catalog catalog) { Model.Local.ArticleCatalogRepository ArticleCatalogRepository = new Model.Local.ArticleCatalogRepository(); //Suppression de tous les liens articles foreach (var articleCatalog in ArticleCatalogRepository.ListCatalog(catalog.Cat_Id)) { ArticleCatalogRepository.Delete(articleCatalog); } //Suppression image Model.Local.CatalogImageRepository CatalogImageRepository = new Model.Local.CatalogImageRepository(); if (catalog.CatalogImage != null && catalog.CatalogImage.Count > 0) { foreach (Model.Local.CatalogImage catalogimage in CatalogImageRepository.ListCatalog(catalog.Cat_Id)) { catalogimage.EraseFiles(); CatalogImageRepository.Delete(catalogimage); } } CatalogRepository.Delete(catalog); // <JG> 04/02/2013 ajout de la tentative de suppression du catalogue Prestashop try { if (catalog.Pre_Id != null) { Model.Prestashop.PsCategoryRepository PsCategoryRepository = new Model.Prestashop.PsCategoryRepository(); if (PsCategoryRepository.ExistId((int)catalog.Pre_Id)) { PsCategoryRepository.Delete(PsCategoryRepository.ReadId((UInt32)catalog.Pre_Id)); Core.Global.LaunchAlternetis_RegenerateCategoryTree(); Core.Global.LaunchAlternetis_ClearSmartyCache(); } } } catch (Exception ex) { Core.Error.SendMailError(ex.ToString()); } this.LoadCatalogs(); }
public string Edit(FormDataCollection form) { var retVal = string.Empty; var operation = form.Get("oper"); var id = form.Get("Id").Split(',')[0].ToInt32(); if (string.IsNullOrEmpty(operation)) { return(retVal); } TimeSlotInfo info; switch (operation) { case "edit": info = CatalogRepository.GetInfo <TimeSlotInfo>(id); if (info != null) { info.Name = form.Get("Name"); info.OrderTime = form.Get("OrderTime").ToInt32(); CatalogRepository.Update(info); } break; case "add": info = new TimeSlotInfo { Name = form.Get("Name"), OrderTime = form.Get("OrderTime").ToInt32() }; CatalogRepository.Create(info); break; case "del": CatalogRepository.Delete <TimeSlotInfo>(id); break; } StoreData.ReloadData <TimeSlotInfo>(); return(retVal); }
public bool Delete(Catalog catalog) { return(_catalogRepository.Delete(catalog)); }