Exemple #1
0
        public async Task <HttpResponseMessage> Edit(Guid code, BankIn bank)
        {
            var input = new BankEdit {
                Bank = bank, Code = code
            };

            return(await this.ProcessActionAsync(input, this.bankService.Edit));
        }
Exemple #2
0
        /// <summary>
        /// Process all Intouch BankEdit CSVs
        /// </summary>
        public static void ProcessBankEditData(DirectoryFile directoryFile)
        {
            List <BankEdit> BankEditODS = new List <BankEdit>();
            List <BankEdit> BankEditNew = new List <BankEdit>();
            int             newRows     = 0;

            try
            {
                logger.Info($"Started processing file [{directoryFile.FileName}]");
                List <string[]> BankEditFileString = new List <string[]>();
                List <BankEdit> BankEditFile       = new List <BankEdit>();
                FileUtility.CSVStringReader(directoryFile.FileContent, ",", BankEditFileString, 9, true);
                foreach (string[] bankEditString in BankEditFileString)
                {
                    BankEdit BankEdit = new BankEdit
                    {
                        FITID           = Convert.ToInt64(bankEditString[0]),
                        EffectiveDate   = Convert.ToDateTime(bankEditString[1]),
                        EffectiveAmount = Convert.ToDecimal(bankEditString[2])
                    };
                    BankEditFile.Add(BankEdit);
                }

                using (BusinessAccountingEntities context = new BusinessAccountingEntities())
                {
                    var query = (from row in context.BankEdit
                                 select row).ToList();
                    BankEditODS = query;
                    foreach (BankEdit bankEdit in BankEditFile)
                    {
                        if (!BankEditODS.Contains(bankEdit))
                        {
                            BankEditNew.Add(bankEdit);
                            newRows++;
                        }
                    }
                    foreach (BankEdit bankEdit in BankEditNew)
                    {
                        context.BankEdit.Add(bankEdit);
                    }
                    context.SaveChanges();
                    logger.Info($"Added [{newRows.ToString()}] rows to ODS from file [{directoryFile.FileName}]");
                    logger.Info($"Finished processing file [{directoryFile.FileName}]");
                }
            }
            catch (Exception e)
            {
                logger.Error($"Exception while trying to process file [{directoryFile.FileName}]. Exception [{e.ToString()}]");
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// The edit of an Bank.
        /// </summary>
        /// <param name="bank">
        /// The bank.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="Exception">
        /// The exception.
        /// </exception>
        public async Task <bool> Edit(BankEdit bank)
        {
            ValidateBankIn(bank.Bank);

            var existCode = await this.bankRepository.ExistsByCode(bank.Code);

            if (!existCode)
            {
                throw new Exception($"Bank with {bank.Code} doesnt exists.");
            }

            var existInOther = await this.bankRepository.ThisSwiftExistsInOther(bank.Code, bank.Bank.Swift);

            if (!existInOther)
            {
                throw new Exception($"The Swift {bank.Bank.Swift} exists in a bank with a diferent then {bank.Code} .");
            }

            var result = await this.bankRepository.Edit(bank.Code, bank.Bank);

            return(result != 0);
        }