Ejemplo n.º 1
0
        public AdobeSignController()
        {
            var adobeSignApiUrl  = repository.GetKeyValue(AdobeSignApiUrlKey);
            var adobeClientIdKey = repository.GetKeyValue(AdobeClientIdKey);
            var adobeSecretCode  = repository.GetKeyValue(AdobeSecretCodeKey);

            client = new AdobeSignREST(adobeSignApiUrl, adobeClientIdKey, adobeSecretCode);
        }
        public IActionResult GetDistributorView(string token)
        {
            string          baseUrl         = repository.GetKeyValue("BMGBaseUrl");// "https://webservice.bevmedia.com/BMGOrderWebService/api";
            ErrorModel      errorModel      = new ErrorModel();
            BevMediaService bevMediaService = new BevMediaService(baseUrl);
            TokenInfo       tokenInfo       = bevMediaService.VerifyToken(token, out var err);

            if (string.IsNullOrWhiteSpace(err))
            {
                DistributorInfo distributor = bevMediaService.GetDistributorInfo(tokenInfo, out var errMsg);
                //RetailerInfo distributor = bevMediaService.GetRetailerInfo(tokenInfo, out var errMsg);
                if (string.IsNullOrWhiteSpace(errMsg))
                {
                    var creditDataList = _context.CreditData
                                         .Where(x => x.DistributorId == tokenInfo.DistributorID)
                                         .Include(files => files.CreditDataFiles)
                                         .ToList();
                    var ws = new AdobeSignWS();
                    foreach (var creditDataEntity in creditDataList)
                    {
                        if (creditDataEntity.Status == CreditAppStatusEnum.OUT_FOR_SIGNATURE.ToString())
                        {
                            var agreement = ws.GetAgreement(creditDataEntity.AdobeSignAgreementId, creditDataEntity.Id.Value);
                            if (agreement.status != creditDataEntity.Status)
                            {
                                creditDataEntity.Status = agreement.status;
                                _context.SaveChanges();
                            }
                        }
                    }
                    var           creditDataListModel = _mapper.Map <List <CreditData> >(creditDataList);
                    List <string> acceptedStatuses    = new List <string> {
                        CreditAppStatusEnum.OUT_FOR_SIGNATURE.ToString(),
                                  CreditAppStatusEnum.SIGNED.ToString(),
                                  CreditAppStatusEnum.APPROVED.ToString(),
                                  CreditAppStatusEnum.DENIED.ToString(),
                    };
                    List <string> editStatuses = new List <string> {
                        CreditAppStatusEnum.SIGNED.ToString(),
                                  CreditAppStatusEnum.APPROVED.ToString(),
                                  CreditAppStatusEnum.DENIED.ToString(),
                    };
                    foreach (var item in creditDataListModel)
                    {
                        if (acceptedStatuses.Contains(item.Status))
                        {
                            item.DistributorStatus = item.Status;
                        }
                        else
                        {
                            item.DistributorStatus = CreditAppStatusEnum.IN_PROGRESS.ToString();
                        }
                        if (editStatuses.Contains(item.Status))
                        {
                            item.CanAddComments = true;
                        }
                    }
                    var distributorViewModel = new DistributorViewModel();
                    distributorViewModel.CreditDataList = creditDataListModel;

                    distributorViewModel.Distributor = new Distributor();
                    distributorViewModel.Distributor.DistributorLogoURL = distributor.DistributorLogoURL;
                    distributorViewModel.Distributor.DistributorName    = distributor.DistributorName;

                    return(View("DistributorView", distributorViewModel));
                }
                else
                {
                    errorModel.Message = errMsg;
                }
            }
            else
            {
                errorModel.Message = err;
            }
            return(View("ErrorView", errorModel));
        }
Ejemplo n.º 3
0
 public AdobeSignWS()
 {
     Url = repository.GetKeyValue(AdobeSignProxyApiUrlKey);
     //Url = @"http://localhost:51201/api/AdobeSign";
     client = new RestClient(Url);
 }