Esempio n. 1
0
        public static async Task <ResultInstruction> GetInstructionDebtorAsync(ResultPaymentMatrix matrix, ResultParticipant participant, ResultParticipant userPart)
        {
            try
            {
                using (CustomWebClient wc = new CustomWebClient())
                {
                    Uri uri = new Uri(Properties.Settings.Default.UrlCen, $"api/v1/resources/instructions/?payment_matrix={matrix.Id}&creditor={participant.Id}&debtor={userPart.Id}&status=Publicado");
                    wc.Headers[HttpRequestHeader.ContentType] = "application/json";
                    string res = await wc.DownloadStringTaskAsync(uri);

                    if (res != null)
                    {
                        Instruction instruction = JsonConvert.DeserializeObject <Instruction>(res, new JsonSerializerSettings {
                            NullValueHandling = NullValueHandling.Ignore
                        });
                        if (instruction.Count > 0)
                        {
                            instruction.Results[0].PaymentMatrix       = matrix;
                            instruction.Results[0].ParticipantCreditor = participant;
                            instruction.Results[0].ParticipantDebtor   = userPart;
                            return(instruction.Results[0]);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(null);
        }
        public static async Task <ResultBillingWindow> GetBillingWindowByIdAsync(ResultPaymentMatrix matrix)
        {
            try
            {
                using (CustomWebClient wc = new CustomWebClient())
                {
                    Uri uri = new Uri(Properties.Settings.Default.UrlCen, $"api/v1/resources/billing-windows/?id={matrix.BillingWindowId}");
                    wc.Headers[HttpRequestHeader.ContentType] = "application/json";
                    string res = await wc.DownloadStringTaskAsync(uri); // GET

                    if (res != null)
                    {
                        BillingWindow b = JsonConvert.DeserializeObject <BillingWindow>(res, new JsonSerializerSettings {
                            NullValueHandling = NullValueHandling.Ignore
                        });
                        return(b.Results[0]);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(null);
        }