コード例 #1
0
        public async Task <IActionResult> DeleteSite(DeleteSiteAddressModel model)
        {
            var appid = await _appRepo.GetAppId(model.AccessToken);

            var site = await _siteRepo.GetSiteByNameUnderApp(model.SiteName, appid);

            await _siteRepo.DeleteSite(site);

            return(this.Protocol(ErrorType.Success, "Successfully deleted your site!"));
        }
コード例 #2
0
        public async Task <IActionResult> DeleteSite(DeleteSiteAddressModel model)
        {
            var appid = _tokenManager.ValidateAccessToken(model.AccessToken);
            var site  = await _dbContext
                        .Sites
                        .Include(t => t.Root)
                        .SingleOrDefaultAsync(t => t.SiteName == model.SiteName);

            if (site == null)
            {
                return(this.Protocol(ErrorType.NotFound, $"Could not find a site with name: '{model.SiteName}'"));
            }
            if (site.AppId != appid)
            {
                return(this.Protocol(ErrorType.Unauthorized, $"The site you tried to delete is not your app's site."));
            }
            await _folderCleaner.DeleteFolderAsync(site.Root);

            _dbContext.Sites.Remove(site);
            await _dbContext.SaveChangesAsync();

            return(this.Protocol(ErrorType.Success, "Successfully deleted your site!"));
        }