public ActionResult <Result <bool> > DeleteTemplate([FromBody] DeleteEntityRQ body) { var entity = _templateRepo.Get(body.Id); var childCnt = _taskRepo.TemplateChildCount(body.Id); if (childCnt > 0) { return(Result <bool> .Fail($"Unable to delete. A total of {childCnt} tasks depend on this template.")); } var success = _microsoftSQLService.DeleteDatabaseIfExists(entity.NameOnServer); if (!success) { return(Result <bool> .Fail("Failed to delete database instance.")); } success = _templateRepo.DeleteTemplate(body.Id, body.TimeStamp); if (success) { return(Result <bool> .Success(true)); } else { return(Result <bool> .Fail("Failed delete record.")); } }
public bool DeleteNode(string nodeid) { bool flag = false; switch (DetermineNodeType(new Node { Id = new Guid(nodeid) })) { case NodeType.CONTENT_TYPE: flag = _currentrepository.DeleteNode(new Node() { Id = new Guid(nodeid) }); break; case NodeType.TEMPLATE_TYPE: { var template = new Template() { Id = Guid.Parse(nodeid) }; template = _templaterepository.GetTemplate(template); foreach (var tmp in template.TemplateFieldMaps) { _fieldrepository.RemoveFieldTemplateRelation(tmp); _fieldrepository.DeleteField(new Field() { Id = tmp.FieldId }); } flag = _currentrepository.DeleteNode(new Node() { Id = new Guid(nodeid) }); _templaterepository.DeleteTemplate(template); } break; case NodeType.MEDIA_TYPE: break; case NodeType.SYSTEM_TYPE: break; case NodeType.FIELD_TYPE: break; } return(flag); }
public IActionResult Delete(long id) { _logger.LogInformation(LoggingEvents.DeleteItem, "Delete Tenplate", id); var item = _templateRepository.Templates.FirstOrDefault(t => t.Id == id); if (item == null) { _logger.LogWarning(LoggingEvents.GetItemNotFound, "Delete Template Not Found", id); return(NotFound()); } _templateRepository.DeleteTemplate(id); return(new NoContentResult()); }