예제 #1
0
        public async Task <ShareholderBankDto> GetID(int ID)
        {
            ShareholderBankDto shareholderBankDto = new ShareholderBankDto();
            ShareholderBank    shareholderBank    = new ShareholderBank();

            try
            {
                int CacheTimeOutInHours = this.configuration.GetValue <int>("MemoryCache:CacheTimeOutInHours");

                if (CacheTimeOutInHours <= 0)
                {
                    CacheTimeOutInHours = 1;
                }

                IEnumerable <ShareholderBank> shareholderBanks = new List <ShareholderBank>();
                shareholderBanks = cache.Get <IEnumerable <ShareholderBank> >(string.Format("{0}", CacheEnum.SHAREHOLDERBANKS.ToString()));

                if (shareholderBanks == null || !shareholderBanks.Any())
                {
                    shareholderBank = await this.shareholderBankRepository.GetByID(ID);

                    return(this.mapper.Map <ShareholderBankDto>(shareholderBank));
                }

                shareholderBankDto = this.mapper.Map <ShareholderBankDto>(shareholderBanks.FirstOrDefault(x => x.ShareholderBankID == ID));
            }
            catch (Exception er) { logger.LogError(string.Format("{0}===================={1}====================\n", DateTime.Now.ToString(), er.ToString())); }

            return(shareholderBankDto);
        }
예제 #2
0
        public async Task DeleteShareholderBank(int bankID)
        {
            try
            {
                ShareholderBank shareholderBank = new ShareholderBank();

                shareholderBank = await this.shareholderBankRepository.GetByID(bankID);

                await shareholderBankRepository.Save();

                cache.Remove(string.Format("{0}", CacheEnum.SHAREHOLDERBANKS.ToString()));
            }
            catch (Exception er) { logger.LogError(string.Format("{0}===================={1}====================\n", DateTime.Now.ToString(), er.ToString())); }
        }
예제 #3
0
        public async Task <ShareholderBankDto> UpdateShareholderBank(int id, ShareholderBankDto shareholderBankDto)
        {
            try
            {
                ShareholderBank shareholderBank = new ShareholderBank();

                shareholderBank = this.mapper.Map <ShareholderBank>(shareholderBankDto);
                shareholderBank = await shareholderBankRepository.Update(shareholderBank);

                await shareholderBankRepository.Save();

                cache.Remove(string.Format("{0}", CacheEnum.SHAREHOLDERBANKS.ToString()));

                shareholderBankDto = this.mapper.Map <ShareholderBankDto>(shareholderBank);
            }
            catch (Exception er) { logger.LogError(string.Format("{0}===================={1}====================\n", DateTime.Now.ToString(), er.ToString())); }

            return(shareholderBankDto);
        }
예제 #4
0
        public async Task <ShareholderBankDto> CreateShareholderBank(ShareholderBankDto shareholderBankDto)
        {
            ShareholderBank shareholderBank = new ShareholderBank();
            IEnumerable <ShareholderBank> checkShareholderBank = new List <ShareholderBank>();

            try
            {
                checkShareholderBank = await this.shareholderBankRepository.Find(x => x.BankID == shareholderBankDto.BankID && x.ShareholderID == shareholderBankDto.ShareholderID);

                if (checkShareholderBank == null || checkShareholderBank.Any())
                {
                    shareholderBank = this.mapper.Map <ShareholderBank>(shareholderBankDto);
                    shareholderBank = await shareholderBankRepository.Create(shareholderBank);

                    await shareholderBankRepository.Save();

                    cache.Remove(string.Format("{0}", CacheEnum.SHAREHOLDERBANKS.ToString()));
                }
            }
            catch (Exception er) { logger.LogError(string.Format("{0}===================={1}====================\n", DateTime.Now.ToString(), er.ToString())); }

            return(this.mapper.Map <ShareholderBankDto>(shareholderBank));
        }
예제 #5
0
        public async Task <ShareholderDto> CreateShareholder(ShareholderDto shareholderDto)
        {
            Shareholder               shareholder           = new Shareholder();
            ShareholderAddress        shareholderAddress    = new ShareholderAddress();
            ShareholderAddressDto     shareholderAddressDto = new ShareholderAddressDto();
            ShareholderBank           shareholderBank       = new ShareholderBank();
            ShareholderBankDto        shareholderBankDto    = new ShareholderBankDto();
            IEnumerable <Shareholder> checkShareholder      = new List <Shareholder>();
            string base64Image = string.Empty;

            try
            {
                if (shareholder.Company)
                {
                    checkShareholder = await this.shareholderRepository.Find(x => x.GSM01 == shareholderDto.GSM01 && x.CompanyName.ToLower().Trim() == shareholderDto.CompanyName.ToLower().Trim());
                }
                else
                {
                    checkShareholder = await this.shareholderRepository.Find(x => x.GSM01 == shareholderDto.GSM01 && x.Lastname.ToLower().Trim() == shareholderDto.Lastname.ToLower().Trim() &&
                                                                             x.Firstname.ToLower().Trim() == shareholderDto.Firstname.ToLower().Trim() && x.Middlename.ToLower().Trim() == shareholderDto.Middlename.ToLower().Trim());
                }
                if (checkShareholder == null || !checkShareholder.Any())
                {
                    //if (!string.IsNullOrEmpty(shareholderDto.ImageString))
                    //{
                    //    string url = this.cache.Get<string>(shareholderDto.ImageString);
                    //    if (!string.IsNullOrEmpty(url))
                    //    {
                    //        base64Image = fileManager.ConvertImageToByte_FromByteToBase64String(url);
                    //        if (!string.IsNullOrEmpty(base64Image))
                    //        {
                    //            shareholderDto.ImageString = base64Image;
                    //            this.fileManager.DeleteFIle(url);
                    //        }
                    //    }
                    //}


                    //shareholderAddressDto = shareholderDto.ShareholderAddress;
                    //shareholderAddressDto.CapturedDate = DateTime.Now;
                    //shareholderDto.ShareholderAddress = new ShareholderAddressDto();
                    //shareholderBankDto = shareholderDto.ShareholderBank;
                    //shareholderBankDto.CapturedDate = DateTime.Now;
                    //shareholderDto.ShareholderBank = new ShareholderBankDto();

                    //shareholderAddress = this.mapper.Map<ShareholderAddress>(shareholderAddressDto);
                    //shareholderBank = this.mapper.Map<ShareholderBank>(shareholderBankDto);
                    shareholder = this.mapper.Map <Shareholder>(shareholderDto);

                    shareholder.ShareholderAddress.CapturedDate = DateTime.Now;
                    shareholder.ShareholderBank.CapturedDate    = DateTime.Now;

                    shareholderAddress = await this.shareholderAddressRepository.Create(shareholder.ShareholderAddress);

                    shareholderBank = await this.shareholderBankRepository.Create(shareholder.ShareholderBank);

                    shareholder = await shareholderRepository.Create(shareholder);

                    await shareholderRepository.Save();

                    shareholder.ShareholderAddressID = shareholderAddress.ShareholderAddressID;
                    shareholderAddress.ShareholderID = shareholder.ShareholderID;
                    shareholder.ShareholderBankID    = shareholderBank.ShareholderBankID;
                    shareholderBank.ShareholderID    = shareholder.ShareholderID;

                    await shareholderRepository.Update(shareholder);

                    await this.shareholderAddressRepository.Update(shareholder.ShareholderAddress);

                    await this.shareholderBankRepository.Update(shareholder.ShareholderBank);

                    await shareholderRepository.Save();

                    cache.Remove(string.Format("{0}", CacheEnum.SHAREHOLDERS.ToString()));
                }
            }
            catch (Exception er) { logger.LogError(string.Format("{0}===================={1}====================\n", DateTime.Now.ToString(), er.ToString())); }

            return(this.mapper.Map <ShareholderDto>(shareholder));
        }