Exemple #1
0
        public IActionResult HardDelete(int id)
        {
            var childrenResponse = _dbHelper.GetEntitiesByQuery(_directoryService.GetAllChildDirectoriesQuery(id));

            if (childrenResponse.Success)
            {
                if (childrenResponse.Data.Any())
                {
                    return(BadRequest($"Directory with id {id} contains child directories. Remove them first"));
                }

                return(ApiResult(_dbHelper.RemoveEntity <Tags>(id)));
            }
            else if (childrenResponse.ReturnCode == ReturnCode.NoEntitiesMatchQuery)
            {
                return(ApiResult(_dbHelper.RemoveEntity <Tags>(id)));
            }

            return(ApiResult(childrenResponse));
        }
Exemple #2
0
        public IQueryable <Notes> GetAllNotesUnderDirectory_Query(int directoryId)
        {
            var childDirectoryIds = _directoryService.GetAllChildDirectoriesQuery(directoryId)
                                    .Select(d => d.TagId);

            return(_relationshipService.GetAllTagNoteRelationshipsQuery()
                   .Where(tr => childDirectoryIds.Contains(tr.TagId) || tr.TagId == directoryId)
                   //.Select(tr => tr.Note)
                   .GroupBy(g => g.NoteId)
                   .Select(g => g.Select(tr => tr.Note).FirstOrDefault()));

            return(_relationshipService.GetAllTagNoteRelationshipsQuery()
                   .Where(tr => childDirectoryIds.Contains(tr.TagId) || tr.TagId == directoryId)
                   .Select(tr => tr.Note));
        }