public CoreResult <IQueryable <Country> > GetAll() { var result = new CoreResult <IQueryable <Country> >(); var ExchangeRate = _countryRateRepository.GetAll().AsNoTracking(); if (ExchangeRate == null) { result.Failed("数据不存在"); return(result); } result.Success(ExchangeRate); return(result); }
public CoreResult <IQueryable <Shop> > GetAll() { var result = new CoreResult <IQueryable <Shop> >(); var shop = _shopRepository.GetAll().AsNoTracking(); if (shop == null) { result.Failed("数据不存在"); return(result); } result.Success(shop); return(result); }
/// <summary> /// 列表数据不分页 /// </summary> /// <returns></returns> public CoreResult <IQueryable <Blog> > GetAll() { var result = new CoreResult <IQueryable <Blog> >(); var post = _blogRepository.GetAll().AsNoTracking(); if (post == null) { result.Failed("数据不存在"); return(result); } result.Success(post); return(result); }
/// <summary> /// 列表数据不分页 /// </summary> /// <returns></returns> public CoreResult <IQueryable <Company> > GetAll() { var result = new CoreResult <IQueryable <Company> >(); var company = _companyRepository.GetAll().AsNoTracking(); if (company == null) { result.Failed("数据不存在"); return(result); } result.Success(company); return(result); }
public async Task <CoreResult> AsyncCountry() { CoreResult result = new CoreResult(); AsyncCountryCommand command = new AsyncCountryCommand(); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("国家同步成功"); } else { result.Failed("国家同步失败"); } return(result); }
public async Task <CoreResult> Update([FromBody] BlogUpdateDto dto) { CoreResult result = new CoreResult(); BlogUpdateCommand command = new BlogUpdateCommand(dto.Id, dto.Name, dto.Url); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("修改成功"); } else { result.Failed("修改失败"); } return(result); }
public async Task <CoreResult> Delete(long Id) { CoreResult result = new CoreResult(); BlogDeleteCommand command = new BlogDeleteCommand(Id); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("删除成功"); } else { result.Failed("删除成功"); } return(result); }
public async Task <CoreResult> Update([FromBody] UpdateCompanyRequestDto dto) { CoreResult result = new CoreResult(); UpdateCompanyCommand command = new UpdateCompanyCommand(dto); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("修改成功"); } else { result.Failed("修改失败"); } return(result); }
public async Task <CoreResult> Create([FromBody] CreateCompanyRequestDto dto) { CoreResult result = new CoreResult(); CreateCompanyCommand command = new CreateCompanyCommand(dto.Name, dto.SkuPrefix, dto.AdditionalFee); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("添加成功"); } else { result.Failed("添加失败"); } return(result); }
public async Task <CoreResult> Create([FromBody] CreateShopRequestDto dto) { CoreResult result = new CoreResult(); CreateShopCommand command = new CreateShopCommand(dto); var res = await _bus.SendCommandAsync(command); if (res) { result.Success("添加成功"); } else { result.Failed("添加失败"); } return(result); }
public async Task <IActionResult> Index() { CoreResult coreResult = new CoreResult(); #region ServiceDiscovery var serviceProvider = new ConsulServiceProvider(new Uri("http://127.0.0.1:8500")); var _userServiceUrl = serviceProvider.CreateServiceBuilder(builder => { builder.ServiceName = "UserApi"; builder.LoadBalancer = TypeLoadBalancer.RoundRobin; builder.UriScheme = Uri.UriSchemeHttp; }).BuildAsync("/api/user/servicesdiscovery").Result; #endregion var polly = PolicyBuilder.CreatePolly(); polly.Execute(() => { try { var form = new Dictionary <string, string>() { { "phone", "18650482503" } }; var response = _httpClient.PostAsync(_userServiceUrl.ToString(), new FormUrlEncodedContent(form)).Result; if (response.StatusCode == HttpStatusCode.OK) { coreResult.Success(response.Content.ReadAsStringAsync().Result); } else { coreResult.Failed(response.Content.ReadAsStringAsync().Result); } } catch (Exception ex) { _logger.LogError("在重试之后失败"); throw new Exception(ex.Message); } }); return(Content(coreResult.Message)); }