public IActionResult Info() { ViewBag.Balance = _balanceService.GetBalanceAsync(LoginInfo.Id).Result; ViewBag.Company = LoginInfo.CompanyName.IsNullOrEmpty() ? "暂无企业信息" : LoginInfo.CompanyName; return(View()); }
public async Task <IActionResult> GetForAddress([FromRoute] string address) { var balance = await _balanceService.GetBalanceAsync(address.ToLowerInvariant()); return(new JsonResult(new BalanceResponse { Amount = balance.ToString() })); }
// // GET: /api/clients/balance /// <summary> /// Gets accumulative client company balance. /// </summary> /// <returns></returns> public async Task <Balance> Get() { // Get company for user DomainCompany company = await _companyService.FindByUserAsync(UserId); decimal balance = await _balanceService.GetBalanceAsync(company.Id); return(new Balance { Amount = balance, Date = DateTime.UtcNow }); }
private async Task <DomainClientForAdmin> GetClientDataAsync(CompanyEntity company) { return(new DomainClientForAdmin { Id = company.Id, Name = company.Name, Email = company.Email, Created = company.Created, Balance = await _balanceService.GetBalanceAsync(company.Id), State = (ResourceState)company.State }); }
public async Task <UrlTrackingResult> TrackAsync(DomainTrackingUrl trackingUrl) { if (string.IsNullOrEmpty(trackingUrl.Id)) { trackingUrl.Id = _urlShortenerService.Decode(trackingUrl.Key).ToString(CultureInfo.InvariantCulture); } TrackingUrlEntity entity = _mappingEngine.Map <DomainTrackingUrl, TrackingUrlEntity>(trackingUrl); entity = await _trackingUrlRepository.GetAsync(entity); if (entity == null) { throw new NotFoundException(string.Format("Could not find tracking url with id {0} and key {1}", trackingUrl.Id, trackingUrl.Key)); } // Build portal url link string projectUrl = _projectUriProvider.GetUri(entity.ProjectId); // We should keep requested schema in redirect link var projectUri = new UriBuilder(projectUrl) { Scheme = trackingUrl.RequestUri.Scheme, Port = trackingUrl.RequestUri.Port }; // Default redirect to Portal var result = new UrlTrackingResult { ProjectId = entity.ProjectId, SubscriptionId = entity.SubscriptionId, IsAccountable = false, Redirect = projectUri.Uri }; DomainCompany company; CompanySubscription subscription; try { company = await _companyService.FindBySubscriptionAsync(entity.SubscriptionId); subscription = await _subscriptionService.GetAsync(entity.SubscriptionId); } catch (ForbiddenException) { // blocked company or subscription - portal redirect return(result); } catch (NotFoundException) { // deleted or unexisting company or subscription - portal redirect return(result); } // Checking custom subscription type if (subscription.Type == SubscriptionType.Pro || subscription.Type == SubscriptionType.Custom) { // always redirect to client site result.Redirect = new Uri(entity.RedirectUrl); result.IsAccountable = true; } else if (subscription.Type == SubscriptionType.Basic) { // checking company balance if (subscription.IsManuallyEnabled || subscription.HasTrialClicks || (await _balanceService.GetBalanceAsync(company.Id)) > 0) { result.Redirect = new Uri(entity.RedirectUrl); result.IsAccountable = true; } } return(result); }