示例#1
0
        public MA_COUNTRY_LIMIT CreateTempLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT record)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (record.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Effective date cannot be set to past date.");

                if (record.EXPIRY_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Expiry date cannot be set to past date.");

                if (record.EXPIRY_DATE <= record.EFFECTIVE_DATE)
                    throw this.CreateException(new Exception(), "Expiry date must be after effective date.");

                var duplicate = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ISTEMP == true && p.ISACTIVE == true
                                                                                                && p.COUNTRY_ID == record.COUNTRY_ID && p.EXPIRY_DATE >= record.EFFECTIVE_DATE);
                if (duplicate != null)
                    throw this.CreateException(new Exception(), "Duplicate temp limit info");

                LogBusiness logBusiness = new LogBusiness();
                var newRecord = new { AMOUNT = record.AMOUNT, EFFECTIVE_DATE = record.EFFECTIVE_DATE, EXPIRY_DATE = record.EXPIRY_DATE };
                unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, record.COUNTRY_ID, LimitLogEvent.TEMP_COUNTRY_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY_LIMIT, "Temp Country Limit", newRecord));

                unitOfWork.MA_COUNTRY_LIMITRepository.Add(record);
                unitOfWork.Commit();
            }

            return record;
        }
示例#2
0
        public MA_USER CreateUser(SessionInfo sessioninfo, MA_USER user)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USERRepository.GetByUserCode(user.USERCODE);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                LogBusiness logBusiness = new LogBusiness();
                unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, user.ID, LogEvent.USER_AUDIT.ToString(), LookupFactorTables.MA_USER, "User", new { }));
                unitOfWork.MA_USERRepository.Add(user);
                unitOfWork.Commit();
            }

            return user;
        }
示例#3
0
        public MA_USER CreateUser(SessionInfo sessioninfo, MA_USER user)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USERRepository.GetByUserCode(user.USERCODE);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }
                LogBusiness logBusiness = new LogBusiness();
                unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, user.ID, LogEvent.USER_AUDIT.ToString(), LookupFactorTables.MA_USER, "User", new { }));
                unitOfWork.MA_USERRepository.Add(user);
                unitOfWork.Commit();
            }

            return(user);
        }
        public MA_INSTRUMENT Create(SessionInfo sessioninfo, MA_INSTRUMENT instrument, ProductCode product)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(product.ToString()).FirstOrDefault(p => p.LABEL == instrument.LABEL);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), "Label is duplicated");
                if (product == ProductCode.BOND)
                {
                    LogBusiness logBusiness = new LogBusiness();
                    unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, instrument.ID, LogEvent.INSTRUMENT_AUDIT.ToString(), LookupFactorTables.MA_INSTRUMENT, "BOND", new { }));
                }
                unitOfWork.MA_INSTRUMENTRepository.Add(instrument);
                unitOfWork.Commit();
            }

            return instrument;
        }
示例#5
0
        public MA_INSTRUMENT Create(SessionInfo sessioninfo, MA_INSTRUMENT instrument, ProductCode product)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_INSTRUMENTRepository.GetAllByProductCode(product.ToString()).FirstOrDefault(p => p.LABEL == instrument.LABEL);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), "Label is duplicated");
                }
                if (product == ProductCode.BOND)
                {
                    LogBusiness logBusiness = new LogBusiness();
                    unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, instrument.ID, LogEvent.INSTRUMENT_AUDIT.ToString(), LookupFactorTables.MA_INSTRUMENT, "BOND", new { }));
                }
                unitOfWork.MA_INSTRUMENTRepository.Add(instrument);
                unitOfWork.Commit();
            }

            return(instrument);
        }
示例#6
0
        public MA_COUTERPARTY Create(SessionInfo sessioninfo, MA_COUTERPARTY counterparty)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate1 = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.USERCODE == counterparty.USERCODE);
                if (checkDuplicate1 != null)
                {
                    throw this.CreateException(new Exception(), "OPICS ID is duplicated");
                }
                var checkDuplicate2 = unitOfWork.MA_COUTERPARTYRepository.All().FirstOrDefault(p => p.SNAME == counterparty.SNAME);
                if (checkDuplicate2 != null)
                {
                    throw this.CreateException(new Exception(), "Short name is duplicated");
                }
                LogBusiness logBusiness = new LogBusiness();
                unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, counterparty.ID, LogEvent.COUNTERPARTY_AUDIT.ToString(), LookupFactorTables.MA_COUTERPARTY, "Counterparty", new { }));
                unitOfWork.MA_COUTERPARTYRepository.Add(counterparty);
                unitOfWork.Commit();
            }

            return(counterparty);
        }
示例#7
0
        public MA_TEMP_CTPY_LIMIT CreateTempLimit(SessionInfo sessioninfo, MA_TEMP_CTPY_LIMIT record)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (record.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate)
                {
                    throw this.CreateException(new Exception(), "Effective date cannot be set to past date.");
                }

                if (record.EXPIRY_DATE < sessioninfo.Process.CurrentDate)
                {
                    throw this.CreateException(new Exception(), "Expiry date cannot be set to past date.");
                }

                if (record.EXPIRY_DATE <= record.EFFECTIVE_DATE)
                {
                    throw this.CreateException(new Exception(), "Expiry date must be after effective date.");
                }

                var duplicate = unitOfWork.MA_TEMP_CTPY_LIMITRepository.All().FirstOrDefault(p => p.CTPY_LIMIT_ID == record.CTPY_LIMIT_ID && p.ISACTIVE == true &&
                                                                                             p.EXPIRY_DATE >= record.EFFECTIVE_DATE);
                if (duplicate != null)
                {
                    throw this.CreateException(new Exception(), "Duplicate temp limit info");
                }

                LogBusiness logBusiness = new LogBusiness();
                var         newRecord   = new { AMOUNT = record.AMOUNT, EFFECTIVE_DATE = record.EFFECTIVE_DATE, EXPIRY_DATE = record.EXPIRY_DATE };

                unitOfWork.DA_LOGGINGRepository.Add(logBusiness.CreateLogging(sessioninfo, record.CTPY_LIMIT_ID, LimitLogEvent.TEMP_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_TEMP_CTPY_LIMIT, "Temp Limit", newRecord));
                unitOfWork.MA_TEMP_CTPY_LIMITRepository.Add(record);
                unitOfWork.Commit();
            }

            return(record);
        }