Exemplo n.º 1
0
        public async Task <ActionResult> Delete(int key)
        {
            if (await _subdomainVersionService.VersionIsASource(key))
            {
                return(BadRequest(
                           "You are not allowed to delete this version because it is using as a source by some other versions"));
            }
            else
            {
                if (!_subdomainVersionService.Remove(key))
                {
                    return(BadRequest("I will add error to here"));
                }

                return(Ok());
            }
        }
        public async Task<bool> Remove(int subdomainId)
        {
            if (subdomainId > 0)
            {
                var subdomain = _subdomainUnitOfWork.SubdomainRepository.GetById(subdomainId);
                var subdomainVersions =
                    await _subdomainUnitOfWork.SubdomainVersionRepository.GetAllSubdomainVersionsBySubdomainId(
                        subdomainId);

                foreach (var version in subdomainVersions)
                {
                     _subdomainVersionService.Remove(version.Id);
                }

                _subdomainUnitOfWork.SubdomainRepository.Remove(subdomain);
                _subdomainUnitOfWork.Complete();
            }
            else
            {
                return false;
            }

            return true;
        }