public static async Task <LimitModel> FindByUser(string userName) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //var url = $"{Constants.URL}{Constants.ENDPOINT_LIMIT}"; var url = new UriBuilder($"{Constants.URL}{Constants.ENDPOINT_LIMIT}") { Query = "user=Frederico" }; HttpResponseMessage response = await client.GetAsync(url.Uri); LimitModel limit = null; if (response.IsSuccessStatusCode) { string responseBody = await response.Content.ReadAsStringAsync(); limit = JsonConvert.DeserializeObject <LimitModel>(responseBody); } return(limit); }
public LimitDetailsView(ILimitService service, LimitModel entity, bool isNew) : base(service, entity, isNew) { InitializeComponent(); // set header and commands panel context LabelHeader.Content = ViewHeader; CommandsPanel.DataContext = Commands; }
public async Task DadoQuePossuaUmLimiteInicialDeReaisAsync(string initialLimit) { Limit limit = new Limit() { User = "******", UserLimit = initialLimit }; this.newLimit = await LimitRepository.UpdateLimit(limit); }
private void OpenDetails(LimitModel model, bool isNew = false) { this.OpenDetailsWindow(new LimitDetailsView(_limitService, model, isNew), () => { // update grid if (isNew) { InsertNewLimit(_viewModel.LimitsViewModel.Entities, model); } GridLimits.Items.Refresh(); NotifyDataChanged(); }); }
/// <summary> /// Creates account limit. /// </summary> /// <param name="accessToken"> /// The access token. /// </param> /// <param name="accountID"> /// The account id. /// </param> /// <returns> /// The account limit. /// </returns> private static async Task <LimitModel> CreateAccountLimit( string accessToken, string accountID) { // Note that limit name should a valid limit defined in the billing plan. // Please use PUT method to update a previously configured limit. var limitToCreate = new LimitModel { Name = "Iam_usersMax", Value = 10m }; // See https://cp.serverdata.net/webservices/restapi/docs-ui/index#!/Account_limits_(end-user_accounts%2C_to_enforce_prepaid_billing_model)/AccountLimitsV1_PostLimit return(await CallUsingHttpClientAsync <LimitModel, LimitModel>( $"{ResourceServerEndpointAddress}/accounts/{accountID}/limits", HttpMethod.Post, accessToken, limitToCreate)); }
public static async Task <LimitModel> UpdateLimit(Limit newLimit) { client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var url = $"{Constants.URL}{Constants.ENDPOINT_LIMIT}"; var requestBody = new StringContent(JsonConvert.SerializeObject(newLimit)); HttpResponseMessage response = await client.PostAsync(url, requestBody); LimitModel limit = null; if (response.IsSuccessStatusCode) { string responseBody = await response.Content.ReadAsStringAsync(); limit = JsonConvert.DeserializeObject <LimitModel>(responseBody); } return(limit); }
private void InsertNewLimit(ObservableCollection <LimitModel> entities, LimitModel model) { // insert new limit if (model.State == LimitState.Planned && entities.Any(x => x.State != Model.Enums.LimitState.Active)) { var firstNonActive = entities.First(x => x.State != LimitState.Active); if (entities.IndexOf(firstNonActive) > 0) { entities.Insert(entities.IndexOf(firstNonActive), model); } else { entities.Insert(0, model); } } else if (model.State == LimitState.Active) { entities.Insert(0, model); } else { entities.Add(model); } }
public async Task EntaoOMeuNovoLimiteDeveSerReais(string value) { LimitModel limit = await LimitRepository.FindByUser("Frederico"); limit.UserLimit.Should().Be(value); }