public async Task <IActionResult> ViewSiteDetail(ViewSiteDetailAddressModel model) { var appid = await _appRepo.GetAppId(model.AccessToken); var site = await _siteRepo.GetSiteByNameUnderApp(model.SiteName, appid); var viewModel = new ViewSiteDetailViewModel { AppId = appid, Site = site, Size = await _folderRepo.GetFolderSize(site.RootFolderId), Code = ErrorType.Success, Message = "Successfully get your site!" }; return(Ok(viewModel)); }
public async Task <IActionResult> ViewSiteDetail(ViewSiteDetailAddressModel model) { var appid = await _tokenManager.ValidateAccessToken(model.AccessToken); var appLocal = await _dbContext.Apps.SingleOrDefaultAsync(t => t.AppId == appid); if (appLocal == null) { appLocal = new ProbeApp { AppId = appid }; _dbContext.Apps.Add(appLocal); await _dbContext.SaveChangesAsync(); } var site = await _dbContext .Sites .Where(t => t.AppId == appid) .Include(t => t.Root) .SingleOrDefaultAsync(t => t.SiteName.ToLower() == model.SiteName.ToLower()); if (site == null) { return(this.Protocol(ErrorType.NotFound, $"Could not find your site with name: {model.SiteName}")); } var viewModel = new ViewSiteDetailViewModel { AppId = appLocal.AppId, Site = site, Size = await _folderCleaner.GetFolderSite(site.Root), Code = ErrorType.Success, Message = "Successfully get your buckets!" }; return(Json(viewModel)); }