Ejemplo n.º 1
0
        public static async Task <List <ResultParticipant> > GetParticipants(string userCEN, Uri url)
        {
            try
            {
                ResultAgent agent = await Agent.GetAgetByEmailAsync(userCEN, url);

                if (agent != null)
                {
                    List <ResultParticipant> participants = new List <ResultParticipant>();
                    foreach (ResultParticipant item in agent.Participants)
                    {
                        ResultParticipant participant = await GetParticipantByIdAsync(item.ParticipantId, url);

                        participants.Add(participant);
                    }
                    // Add Cve 76.532.358-4
                    participants.Insert(0, new ResultParticipant {
                        Name = "Please select a Company"
                    });
                    participants.Insert(1, new ResultParticipant {
                        Name = "CVE Renovable", Rut = "76532358", VerificationCode = "4", Id = 999, IsCoordinator = false
                    });

                    return(participants);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(null);
        }
Ejemplo n.º 2
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);
        }