Example #1
0
        public async Task <string> AddEditProgramInfo(ProgramInfoDto model, string clientIpAddress)
        {
            try
            {
                string prgTp   = string.Empty;
                var    id      = model.JPOS_IssuerId;
                var    prgType = (await _programTypeService.GetProgramTypesDetailByIds(new List <int> {
                    model.ProgramTypeId.Value
                })).ToList();
                if (prgType.Count > 0)
                {
                    prgTp = prgType.Select(x => x.ProgramTypeName).FirstOrDefault();
                }
                var oIssuerJPOS = new IssuerJPOSDto()
                {
                    active         = true,
                    programId      = model.ProgramCodeId,
                    name           = model.name,
                    tz             = model.timeZone,
                    organizationId = model.OrganisationJPOSId,
                    address1       = model.address,
                    city           = model.city,
                    country        = model.country,
                    programType    = prgTp,
                    state          = model.state,
                    website        = model.website,
                    zip            = model.zipcode
                };
                int result = await _sharedJPOSService.PostRespectiveDataJPOS(JPOSAPIURLConstants.Issuers, oIssuerJPOS, id, clientIpAddress, JPOSAPIConstants.Issuers);

                if (result > 0 && model.id <= 0)
                {
                    model.JPOS_IssuerId = result.ToString();
                }
                var chkExist = await FindAsync(new { model.id });

                if (chkExist == null)
                {
                    chkExist = new Program();
                }
                if (model.name != null)
                {
                    chkExist.name = model.name;
                }
                chkExist.organisationId        = model.organisationId;
                chkExist.AccountHolderGroups   = model.AccountHolderGroups;
                chkExist.AccountHolderUniqueId = model.AccountHolderUniqueId;
                chkExist.address   = model.address;
                chkExist.city      = model.city;
                chkExist.colorCode = model.colorCode;
                chkExist.country   = model.country;
                if (model.createdBy != null)
                {
                    chkExist.createdBy = model.createdBy;
                }
                if (model.createdDate != null)
                {
                    chkExist.createdDate = model.createdDate;
                }
                chkExist.customErrorMessaging = model.customErrorMessaging;
                chkExist.customInputMask      = model.customInputMask;
                chkExist.customInstructions   = model.customInstructions;
                chkExist.customName           = model.customName;
                chkExist.description          = model.description;
                if (model.isActive != null)
                {
                    chkExist.isActive = model.isActive;
                }
                if (model.isDeleted != null)
                {
                    chkExist.isDeleted = model.isDeleted;
                }
                if (model.modifiedBy != null)
                {
                    chkExist.modifiedBy = model.modifiedBy;
                }
                if (model.modifiedDate != null)
                {
                    chkExist.modifiedDate = model.modifiedDate;
                }
                if (model.ProgramCodeId != null)
                {
                    chkExist.ProgramCodeId = model.ProgramCodeId;
                }
                chkExist.programCustomFields = model.programCustomFields;
                chkExist.ProgramTypeId       = model.ProgramTypeId;
                chkExist.state    = model.state;
                chkExist.timeZone = model.timeZone;
                chkExist.website  = model.website;
                chkExist.zipcode  = model.zipcode;
                chkExist.id       = model.id;
                chkExist.IsAllNotificationShow = model.IsAllNotificationShow;
                chkExist.IsRewardsShowInApp    = model.IsRewardsShowInApp;
                chkExist.JPOS_IssuerId         = model.JPOS_IssuerId;
                var resultPrg = await InsertOrUpdateAsync(chkExist, new { model.id });

                await _orgProgram.AddSpecificOrganisationProgram(resultPrg, model.organisationId);

                return(Cryptography.EncryptPlainToCipher(Convert.ToString(resultPrg)));
            }
            catch (Exception)
            {
                throw;
            }
        }