Пример #1
0
 private void UpdateAllAgreementsStatuses()
 {
     using (var context = new CreditAppContext())
     {
         var creditDataEntities = context.CreditData.Where(x => x.Status != "SIGNED" && x.AdobeSignAgreementId != null && x.AdobeSignAgreementId != "").ToList();
         if (creditDataEntities.Any())
         {
             this.RefreshToken(null);
             foreach (var creditDataEntity in creditDataEntities)
             {
                 var response = client.GetAgreement(creditDataEntity.Id, creditDataEntity.AdobeSignAgreementId);
                 repository.AddAdobeSignLog(creditDataEntity.Id, "UpdateAgreementStatus", $"agreementId={creditDataEntity.AdobeSignAgreementId}", response);
                 if (response.status == "CANCELLED")
                 {
                     creditDataEntity.Status               = null;
                     creditDataEntity.SigningUrl           = null;
                     creditDataEntity.AdobeSignAgreementId = null;
                 }
                 else
                 {
                     creditDataEntity.Status = response.status;
                 }
                 context.SaveChanges();
             }
         }
     }
 }
Пример #2
0
        public Task <bool> UpdateCreditApplicationStatus([FromBody] WebHookInfo webHookInfo)
        {
            using (var context = new CreditAppContext())
            {
                var creditDataEntity = context.CreditData.SingleOrDefault(x =>
                                                                          x.AdobeSignAgreementId == webHookInfo.agreement.id);
                if (creditDataEntity != null)
                {
                    creditDataEntity.Status = webHookInfo.Event;

                    context.Update(creditDataEntity);
                    context.SaveChanges();
                }
            }
            //log
            repository.AddAdobeSignLog("UpdateCreditApplicationStatus", $"AgreementId={webHookInfo.agreement.id}", webHookInfo.ToJson());

            return(Task.FromResult(true));
        }
 public CreditDataController(IMapper mapper, CreditAppContext context)
 {
     _mapper  = mapper;
     _context = context;
 }