コード例 #1
0
        public MA_COUNTRY Create(SessionInfo sessioninfo, MA_COUNTRY country)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate1 = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.LABEL == country.LABEL);
                if (checkDuplicate1 != null)
                    throw this.CreateException(new Exception(), "Short name is duplicated");

                //Prepare Country-Limit data
                MA_COUNTRY_LIMIT ctLimit = new MA_COUNTRY_LIMIT();

                ctLimit.ID = Guid.NewGuid();
                ctLimit.COUNTRY_ID = country.ID;
                ctLimit.AMOUNT = 0;
                ctLimit.EFFECTIVE_DATE = sessioninfo.Process.CurrentDate;
                ctLimit.EXPIRY_DATE = sessioninfo.Process.CurrentDate;
                ctLimit.ISACTIVE = true;
                ctLimit.ISTEMP = false;
                ctLimit.FLAG_CONTROL = true;
                ctLimit.LOG.INSERTDATE = DateTime.Now;
                ctLimit.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;

                unitOfWork.MA_COUNTRYRepository.Add(country);
                unitOfWork.MA_COUNTRY_LIMITRepository.Add(ctLimit);
                unitOfWork.Commit();
            }

            return country;
        }
コード例 #2
0
ファイル: AuditBusiness.cs プロジェクト: Theeranit/DealMarker
        public void TraceAuditLoginUser(SessionInfo sessioninfo)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {

                List<DA_LOGIN_AUDIT> foundaudits = unitOfWork.DA_LOGIN_AUDITRepository.GetByUserID(sessioninfo.CurrentUserId);
                if (foundaudits.Count > 0)
                {
                    foreach (DA_LOGIN_AUDIT foundaudit in foundaudits.Where(p => !p.LOGOUT_DATE.HasValue))
                    {
                        foundaudit.LOGOUT_DATE = DateTime.Now;
                        foundaudit.RESULT = String.Format("Logout the system on {0}, because someone use this user to login the system from another machine or computer place.", DateTime.Now.ToString());
                    }
                }
                DA_LOGIN_AUDIT audit = new DA_LOGIN_AUDIT();
                audit.ID = sessioninfo.ID;
                audit.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;
                audit.LOG.INSERTDATE = DateTime.Now;
                audit.LOGON_DATE = DateTime.Now;
                audit.RESULT = "Logon System";
                audit.TERMINAL = sessioninfo.IPAddress;
                audit.USER_ID = sessioninfo.CurrentUserId;
                unitOfWork.DA_LOGIN_AUDITRepository.Add(audit);
                unitOfWork.Commit();
            }
        }
コード例 #3
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;
        }
コード例 #4
0
ファイル: DealBusiness.cs プロジェクト: Theeranit/DealMarker
 public DA_TRN CancelDeal(SessionInfo sessioninfo, DA_TRN trn)
 {
     LookupBusiness _lookupBusiness = new LookupBusiness();
     using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
     {
         var foundTrn = unitOfWork.DA_TRNRepository.GetById(trn.ID,true);
         if (foundTrn == null)
             throw this.CreateException(new Exception(), "Data not found!");
         else if (!Guid.Equals(foundTrn.LOG.INSERTBYUSERID, sessioninfo.CurrentUserId))
         {
             throw this.CreateException(new Exception(), "You have no right to cancel this transaction");
         }
         else if (!(foundTrn.ENGINE_DATE.Date == sessioninfo.Process.CurrentDate && foundTrn.SOURCE == "INT"))
         {
             throw this.CreateException(new Exception(), "You cannot cancel the past deals");
         }
         else
         {
             //foundTrn.STATUS_ID = new Guid("1ccd7506-b98c-4afa-838e-24378d9b3c2e");
             foundTrn.REMARK = trn.REMARK;
             foundTrn.STATUS_ID = _lookupBusiness.GetStatusAll().FirstOrDefault(p => p.LABEL == StatusCode.CANCELLED.ToString()).ID;
             foundTrn.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
             foundTrn.LOG.MODIFYDATE = DateTime.Now;
             trn = foundTrn;
             unitOfWork.Commit();
         }
     }
     return trn;
 }
コード例 #5
0
ファイル: UserBusiness.cs プロジェクト: Theeranit/DealMarker
 public void DeleteUser(SessionInfo sessioninfo, Guid ID)
 {
     using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
     {
         var foundUser = unitOfWork.MA_USERRepository.All().FirstOrDefault(p => p.ID == ID);
         unitOfWork.MA_USERRepository.Delete(foundUser);
         unitOfWork.Commit();
     }
 }
コード例 #6
0
        public void ImportCashflows(SessionInfo sessioninfo, List<DA_TRN_CASHFLOW> cashflows)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                foreach (DA_TRN_CASHFLOW cashflow in cashflows)
                {
                    unitOfWork.DA_TRN_CASHFLOWRepository.Add(cashflow);
                }

                unitOfWork.Commit();
            }
        }
コード例 #7
0
 public void DeleteProfileFunction(SessionInfo sessioninfo, Guid guID)
 {
     using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
     {
         var foundprofilefunction = unitOfWork.MA_PROFILE_FUNCTIONALRepository.All().FirstOrDefault(p => p.ID == guID);
         if (foundprofilefunction == null)
             throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
         else
         {
             unitOfWork.MA_PROFILE_FUNCTIONALRepository.Delete(foundprofilefunction);
             unitOfWork.Commit();
         }
     }
 }
コード例 #8
0
        public MA_FUNCTIONAL CreateFunction(SessionInfo sessioninfo, MA_FUNCTIONAL function)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_FUNCTIONALRepository.GetAll().FirstOrDefault(p => p.USERCODE.ToLower().Equals(function.USERCODE.ToLower()));
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                unitOfWork.MA_FUNCTIONALRepository.Add(function);
                unitOfWork.Commit();
            }

            return function;
        }
コード例 #9
0
        public MA_PCCF CreatePCCF(SessionInfo sessioninfo, MA_PCCF pccf)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PCCFRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(pccf.LABEL.ToLower()));
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                unitOfWork.MA_PCCFRepository.Add(pccf);
                unitOfWork.Commit();
            }

            return pccf;
        }
コード例 #10
0
ファイル: AuditBusiness.cs プロジェクト: Theeranit/DealMarker
 public void TraceAuditLogoutUser(SessionInfo sessioninfo)
 {
     using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
     {
         //DA_LOGIN_AUDIT foundaudit = unitOfWork.DA_LOGIN_AUDITRepository.GetBySessionInfo(sessioninfo);
         DA_LOGIN_AUDIT foundaudit = unitOfWork.DA_LOGIN_AUDITRepository.GetByID(sessioninfo.ID);
         if (foundaudit != null)
         {
             foundaudit.LOGOUT_DATE = DateTime.Now;
             foundaudit.RESULT = String.Format("Logout the system on {0}", DateTime.Now.ToString());
         }
         unitOfWork.Commit();
     }
 }
コード例 #11
0
        public MA_USER_PROFILE CreateUserProfile(SessionInfo sessioninfo, MA_USER_PROFILE userprofile)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USER_PROFILERepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(userprofile.LABEL.ToLower()));
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), "Profile is duplicated");

                unitOfWork.MA_USER_PROFILERepository.Add(userprofile);
                unitOfWork.Commit();
            }

            return userprofile;
        }
コード例 #12
0
        public MA_LIMIT_PRODUCT CreateLimitProduct(SessionInfo sessioninfo, MA_LIMIT_PRODUCT limitproduct)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (ValidateProfileFunction(limitproduct))
                {
                    unitOfWork.MA_LIMIT_PRODUCTRepository.Add(limitproduct);
                    unitOfWork.Commit();
                }
                else
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
            }

            return limitproduct;
        }
コード例 #13
0
ファイル: UserBusiness.cs プロジェクト: Theeranit/DealMarker
        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;
        }
コード例 #14
0
        public MA_PROFILE_FUNCTIONAL CreateProfileFunction(SessionInfo sessioninfo, MA_PROFILE_FUNCTIONAL profilefunction)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (ValidateProfileFunction(profilefunction))
                {
                    unitOfWork.MA_PROFILE_FUNCTIONALRepository.Add(profilefunction);
                    unitOfWork.Commit();
                }
                else
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
            }

            return profilefunction;
        }
コード例 #15
0
        public void UpdateDealReconcile(SessionInfo sessioninfo, List<DealTranModel> trns)
        {
            DealBusiness _dealBusiness = new DealBusiness();
            LoggingHelper.Debug("Begin UpdateDealReconcile....");
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                foreach (DealTranModel tran in trns)
                {
                    switch (tran.UpdateStates)
                    {
                        case UpdateStates.Adding:
                            unitOfWork.DA_TRNRepository.Add(tran.Transaction);
                            LoggingHelper.Debug(String.Format("Insert DA_TRN {0} [{1}] is completed", tran.Transaction.INT_DEAL_NO, tran.Transaction.ID.ToString()));
                            break;
                        case  UpdateStates.Editing:
                            var update = unitOfWork.DA_TRNRepository.All().FirstOrDefault(p => p.ID == tran.Transaction.ID);
                            if (update == null)
                                throw this.CreateException(new Exception(), "Data not found!");
                            else
                            {
                                update.EXT_DEAL_NO = tran.Transaction.EXT_DEAL_NO;
                                update.EXT_PORTFOLIO = tran.Transaction.EXT_PORTFOLIO;
                                update.MATURITY_DATE = tran.Transaction.MATURITY_DATE;
                                update.STATUS_ID = tran.Transaction.STATUS_ID;
                                update.LOG.MODIFYBYUSERID = tran.Transaction.LOG.MODIFYBYUSERID;
                                update.LOG.MODIFYDATE = tran.Transaction.LOG.MODIFYDATE;
                                update.INSERT_BY_EXT = tran.Transaction.INSERT_BY_EXT;

                            }
                            LoggingHelper.Debug(String.Format("Update DA_TRN {0} [{1}] is completed", update.INT_DEAL_NO, update.ID.ToString()));
                            break;
                        case UpdateStates.Deleting:
                            var delete = unitOfWork.DA_TRNRepository.All().FirstOrDefault(p => p.ID == tran.Transaction.ID);
                            if (delete == null)
                                throw this.CreateException(new Exception(), "Data not found!");
                            else
                                unitOfWork.DA_TRNRepository.Delete(delete);

                            LoggingHelper.Debug(String.Format("Delete DA_TRN {0} [{1}] is completed", delete.INT_DEAL_NO, delete.ID.ToString()));
                            break;
                    }
                }

                unitOfWork.Commit();

                LoggingHelper.Debug("Commit UpdateDealReconcile....");
            }
        }
コード例 #16
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;
        }
コード例 #17
0
        public MA_PROCESS_DATE Update(SessionInfo sessioninfo, MA_PROCESS_DATE processdate)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var found = unitOfWork.MA_PROCESS_DATERepository.All().First();
                if (found == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {

                    found.NEXT_PROC_DATE = processdate.NEXT_PROC_DATE;
                    found.PREV_PROC_DATE = processdate.PREV_PROC_DATE;
                    found.PROC_DATE = processdate.PROC_DATE;
                    found.FLAG_RECONCILE = processdate.FLAG_RECONCILE;
                    found.LOG.MODIFYBYUSERID = processdate.LOG.MODIFYBYUSERID;
                    found.LOG.MODIFYDATE = processdate.LOG.MODIFYDATE;
                    found.FLAG_RECONCILE = processdate.FLAG_RECONCILE;
                    unitOfWork.Commit();

                }
            }

            return processdate;
        }
コード例 #18
0
ファイル: DealBusiness.cs プロジェクト: Theeranit/DealMarker
        public void UpdateFISendReport(SessionInfo sessioninfo ,Guid[] IDs)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
             {
                     foreach (Guid id in IDs)
                     {
                         var update = unitOfWork.DA_TMBA_EXTENSIONRepository.All().FirstOrDefault(p => p.ID == id);
                         if (update == null)
                             throw this.CreateException(new Exception(), "Data not found!");
                         else
                         {
                             update.SEND_DATE = DateTime.Now;
                             update.SENDER_ID = sessioninfo.CurrentUserId;
                         }

                     }
                     unitOfWork.Commit();
             }
        }
コード例 #19
0
        public MA_FUNCTIONAL UpdateFunction(SessionInfo sessioninfo, MA_FUNCTIONAL function)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_FUNCTIONALRepository.GetAll().FirstOrDefault(p => p.USERCODE.ToLower().Equals(function.USERCODE.ToLower()) && p.ID != function.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                var foundfunction = unitOfWork.MA_FUNCTIONALRepository.All().FirstOrDefault(p => p.ID == function.ID);
                if (foundfunction == null)
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                else
                {

                    foundfunction.ID = function.ID;
                    foundfunction.LABEL = function.LABEL;
                    foundfunction.ISACTIVE = function.ISACTIVE;
                    foundfunction.USERCODE = function.USERCODE;
                    unitOfWork.Commit();

                }
            }

            return function;
        }
コード例 #20
0
ファイル: UserBusiness.cs プロジェクト: Theeranit/DealMarker
        public MA_USER UpdateUser(SessionInfo sessioninfo, MA_USER user)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USERRepository.GetAll().FirstOrDefault(p => p.USERCODE.ToLower() == user.USERCODE.ToLower() && p.ID != user.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                var foundUser = unitOfWork.MA_USERRepository.GetAll().FirstOrDefault(p => p.ID == user.ID);
                if (foundUser == null)
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                else
                {
                    LogBusiness logBusiness = new LogBusiness();
                    var oldRecord = new {

                        DEPARTMENT = foundUser.DEPARTMENT, ISACTIVE = foundUser.ISACTIVE
                        , ISLOCKED = foundUser.ISLOCKED, NAME = foundUser.NAME
                        , USERCODE = foundUser.USERCODE, USER_OPICS = foundUser.USER_OPICS
                        , USER_PROFILE = foundUser.MA_USER_PROFILE.LABEL
                    };
                    var newRecord = new
                    {
                        DEPARTMENT = user.DEPARTMENT, ISACTIVE = user.ISACTIVE
                        , ISLOCKED = user.ISLOCKED, NAME = user.NAME
                        , USERCODE = user.USERCODE, USER_OPICS = user.USER_OPICS
                        , USER_PROFILE = unitOfWork.MA_USER_PROFILERepository.All().FirstOrDefault(p=> p.ID== user.USER_PROFILE_ID).LABEL
                    };

                    var log = logBusiness.UpdateLogging(sessioninfo, foundUser.ID, LogEvent.USER_AUDIT.ToString(), LookupFactorTables.MA_USER, oldRecord, newRecord);
                    if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log);
                    foundUser.ID = user.ID;
                    foundUser.DEPARTMENT = user.DEPARTMENT;
                    foundUser.ISACTIVE = user.ISACTIVE;
                    foundUser.ISLOCKED = user.ISLOCKED;
                    foundUser.LOG.MODIFYBYUSERID = user.LOG.MODIFYBYUSERID;
                    foundUser.LOG.MODIFYDATE = user.LOG.MODIFYDATE;
                    foundUser.NAME = user.NAME;
                    foundUser.USERCODE = user.USERCODE;
                    foundUser.USER_OPICS = user.USER_OPICS;
                    foundUser.USER_PROFILE_ID = user.USER_PROFILE_ID;

                    unitOfWork.Commit();

                }
            }

            return user;
        }
コード例 #21
0
        public MA_INSTRUMENT Update(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 && p.ID != instrument.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), "Label is duplicated");
                var foundData = unitOfWork.MA_INSTRUMENTRepository.GetAll().FirstOrDefault(p => p.ID == instrument.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    if (product == ProductCode.BOND)
                    {
                        LogBusiness logBusiness = new LogBusiness();
                        var oldRecord = new
                        {
                                    ISACTIVE = foundData.ISACTIVE,
                                    CAL_METHOD = foundData.CAL_METHOD,
                                    COUPON = foundData.COUPON,
                                    COUPON_FREQ_TYPE = foundData.MA_FREQ_TYPE!= null ?foundData.MA_PRODUCT.LABEL:string.Empty,
                                    FLAG_FIXED = foundData.FLAG_FIXED,
                                    INS_MKT = foundData.INS_MKT,
                                    ISSUER = foundData.ISSUER,
                                    LABEL = foundData.LABEL,
                                    LOT_SIZE = foundData.LOT_SIZE,
                                    MATURITY_DATE = foundData.MATURITY_DATE,
                                    PRODUCT = foundData.MA_PRODUCT!= null ? foundData.MA_PRODUCT.LABEL:string.Empty,
                                    CURRENCY = foundData.MA_CURRENCY != null ? foundData.MA_CURRENCY.LABEL:string.Empty
                        };
                        var newRecord = new
                        {
                                    ISACTIVE = instrument.ISACTIVE,
                                    CAL_METHOD = instrument.CAL_METHOD,
                                    COUPON = instrument.COUPON,
                                    COUPON_FREQ_TYPE =unitOfWork.MA_FREQ_TYPERepository.All().FirstOrDefault(f=>f.ID==instrument.COUPON_FREQ_TYPE_ID).LABEL,
                                    FLAG_FIXED = instrument.FLAG_FIXED,
                                    INS_MKT = instrument.INS_MKT,
                                    ISSUER = instrument.ISSUER,
                                    LABEL = instrument.LABEL,
                                    LOT_SIZE = instrument.LOT_SIZE,
                                    MATURITY_DATE = instrument.MATURITY_DATE,
                                    PRODUCT = unitOfWork.MA_PRODUCTRepository.All().FirstOrDefault(p => p.ID == instrument.PRODUCT_ID).LABEL,
                                    CURRENCY = unitOfWork.MA_CURRENCYRepository.All().FirstOrDefault(c => c.ID == instrument.CURRENCY_ID1).LABEL,
                        };
                        var log = logBusiness.UpdateLogging(sessioninfo, foundData.ID, LogEvent.INSTRUMENT_AUDIT.ToString(), LookupFactorTables.MA_INSTRUMENT, oldRecord, newRecord);
                        if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log);
                    }
                    foundData.ID = instrument.ID;
                    foundData.ISACTIVE = instrument.ISACTIVE;
                    foundData.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                    foundData.LOG.MODIFYDATE = DateTime.Now;
                    foundData.CAL_METHOD = instrument.CAL_METHOD;
                    foundData.COUPON = instrument.COUPON;
                    foundData.COUPON_FREQ_TYPE_ID = instrument.COUPON_FREQ_TYPE_ID;
                    foundData.FLAG_FIXED = instrument.FLAG_FIXED;
                    foundData.INS_MKT = instrument.INS_MKT;
                    foundData.ISSUER = instrument.ISSUER;
                    foundData.LABEL = instrument.LABEL;
                    foundData.LOT_SIZE = instrument.LOT_SIZE;
                    foundData.MATURITY_DATE = instrument.MATURITY_DATE;
                    foundData.PRODUCT_ID = instrument.PRODUCT_ID;
                    foundData.CURRENCY_ID1 = instrument.CURRENCY_ID1;
                    foundData.CURRENCY_ID2 = instrument.CURRENCY_ID2;
                    unitOfWork.Commit();

                }
            }

            return instrument;
        }
コード例 #22
0
        public MA_COUNTRY_LIMIT UpdateCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT countryLimit)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (countryLimit.EXPIRY_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Expiry date cannot be set to past date.");

                var foundData = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ID == countryLimit.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    LogBusiness logBusiness = new LogBusiness();
                    var oldRecord = new { AMOUNT = foundData.AMOUNT.ToString("#,##0"), EXPIRE_DATE = foundData.EXPIRY_DATE };
                    var newRecord = new { AMOUNT = countryLimit.AMOUNT.ToString("#,##0"), EXPIRE_DATE = countryLimit.EXPIRY_DATE };
                    var log = logBusiness.UpdateLogging(sessioninfo, foundData.COUNTRY_ID, LimitLogEvent.COUNTRY_LIMIY_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY, oldRecord, newRecord, "Country Limit");
                    if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log);

                    foundData.AMOUNT = countryLimit.AMOUNT;
                    foundData.FLAG_CONTROL = countryLimit.FLAG_CONTROL;
                    foundData.EXPIRY_DATE = countryLimit.EXPIRY_DATE;
                    foundData.LOG.MODIFYBYUSERID = countryLimit.LOG.MODIFYBYUSERID;
                    foundData.LOG.MODIFYDATE = countryLimit.LOG.MODIFYDATE;

                    unitOfWork.Commit();
                }
            }

            return countryLimit;
        }
コード例 #23
0
        public MA_COUNTRY_LIMIT UpdateTempCountryLimit(SessionInfo sessioninfo, MA_COUNTRY_LIMIT countryLimit)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                if (countryLimit.EFFECTIVE_DATE < sessioninfo.Process.CurrentDate)
                    throw this.CreateException(new Exception(), "Effective date cannot be set to past date.");

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

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

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

                var foundData = unitOfWork.MA_COUNTRY_LIMITRepository.All().FirstOrDefault(p => p.ID == countryLimit.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    LogBusiness logBusiness = new LogBusiness();
                    var oldRecord = new { AMOUNT = foundData.AMOUNT.ToString("#,##0"), EFFECTIVE_DATE = foundData.EFFECTIVE_DATE, EXPIRE_DATE = foundData.EXPIRY_DATE, ISACTIVE = foundData.ISACTIVE };
                    var newRecord = new { AMOUNT = countryLimit.AMOUNT.ToString("#,##0"), EFFECTIVE_DATE = countryLimit.EFFECTIVE_DATE, EXPIRE_DATE = countryLimit.EXPIRY_DATE, ISACTIVE = countryLimit.ISACTIVE };
                    var log = logBusiness.UpdateLogging(sessioninfo, foundData.COUNTRY_ID, LimitLogEvent.TEMP_COUNTRY_LIMIT_AUDIT.ToString(), LookupFactorTables.MA_COUNTRY_LIMIT, oldRecord, newRecord, "Temp Country Limit");
                    if (log != null) unitOfWork.DA_LOGGINGRepository.Add(log);

                    foundData.AMOUNT = countryLimit.AMOUNT;
                    foundData.ISACTIVE = countryLimit.ISACTIVE;
                    foundData.EFFECTIVE_DATE = countryLimit.EFFECTIVE_DATE;
                    foundData.EXPIRY_DATE = countryLimit.EXPIRY_DATE;
                    foundData.LOG.MODIFYBYUSERID = countryLimit.LOG.MODIFYBYUSERID;
                    foundData.LOG.MODIFYDATE = countryLimit.LOG.MODIFYDATE;

                    unitOfWork.Commit();
                }
            }

            return countryLimit;
        }
コード例 #24
0
        public void UpdatePCCF(SessionInfo sessioninfo, MA_PCCF pccf)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PCCFRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(pccf.LABEL.ToLower()) && p.ID != pccf.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                var foundPCCF = unitOfWork.MA_PCCFRepository.All().FirstOrDefault(p => p.ID == pccf.ID);
                if (foundPCCF == null)
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                else
                {
                    foundPCCF.LABEL = pccf.LABEL;
                    foundPCCF.C1 = pccf.C1;
                    foundPCCF.C2 = pccf.C2;
                    foundPCCF.C3 = pccf.C3;
                    foundPCCF.C4 = pccf.C4;
                    foundPCCF.C5 = pccf.C5;
                    foundPCCF.C6 = pccf.C6;
                    foundPCCF.C7 = pccf.C7;
                    foundPCCF.C8 = pccf.C8;
                    foundPCCF.C9 = pccf.C9;
                    foundPCCF.C10 = pccf.C10;
                    foundPCCF.C11 = pccf.C11;
                    foundPCCF.C12 = pccf.C12;
                    foundPCCF.C13 = pccf.C13;
                    foundPCCF.C14 = pccf.C14;
                    foundPCCF.C15 = pccf.C15;
                    foundPCCF.C16 = pccf.C16;
                    foundPCCF.C17 = pccf.C17;
                    foundPCCF.C18 = pccf.C18;
                    foundPCCF.C19 = pccf.C19;
                    foundPCCF.C20 = pccf.C20;
                    foundPCCF.C1D = pccf.C1D;
                    foundPCCF.C0D = pccf.C0D;
                    foundPCCF.C21 = pccf.C21;
                    foundPCCF.C22 = pccf.C22;
                    foundPCCF.C23 = pccf.C23;
                    foundPCCF.C24 = pccf.C24;
                    foundPCCF.DEFAULT = pccf.DEFAULT;
                    foundPCCF.more20 = pccf.more20;
                    foundPCCF.ISACTIVE = pccf.ISACTIVE;
                    foundPCCF.LOG.MODIFYBYUSERID = pccf.LOG.MODIFYBYUSERID;
                    foundPCCF.LOG.MODIFYDATE = pccf.LOG.MODIFYDATE;
                    unitOfWork.Commit();
                }
            }
        }
コード例 #25
0
        public MA_COUNTRY Update(SessionInfo sessioninfo, MA_COUNTRY country)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate1 = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.LABEL == country.LABEL && p.ID != country.ID);
                if (checkDuplicate1 != null)
                    throw this.CreateException(new Exception(), "Short name is duplicated");

                var foundData = unitOfWork.MA_COUNTRYRepository.All().FirstOrDefault(p => p.ID == country.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    foundData.LABEL = country.LABEL;
                    foundData.DESCRIPTION = country.DESCRIPTION;

                    unitOfWork.Commit();

                }
            }

            return country;
        }
コード例 #26
0
        public MA_LIMIT_PRODUCT UpdateLimitProduct(SessionInfo sessioninfo, MA_LIMIT_PRODUCT limitproduct)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_LIMIT_PRODUCTRepository.GetAll().FirstOrDefault(p => p.LIMIT_ID == limitproduct.LIMIT_ID & p.PRODUCT_ID == limitproduct.PRODUCT_ID && p.ID != limitproduct.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                var foundlimitproduct = unitOfWork.MA_LIMIT_PRODUCTRepository.All().FirstOrDefault(p => p.ID == limitproduct.ID);
                if (foundlimitproduct == null)
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                else
                {

                    foundlimitproduct.ID = limitproduct.ID;
                    foundlimitproduct.LIMIT_ID = limitproduct.LIMIT_ID;
                    foundlimitproduct.MA_LIMIT = limitproduct.MA_LIMIT;
                    foundlimitproduct.MA_PRODUCT = limitproduct.MA_PRODUCT;
                    foundlimitproduct.PRODUCT_ID = limitproduct.PRODUCT_ID;

                    unitOfWork.Commit();

                }
            }

            return limitproduct;
        }
コード例 #27
0
        public MA_USER_PROFILE UpdateUserProfile(SessionInfo sessioninfo, MA_USER_PROFILE userprofile)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_USER_PROFILERepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(userprofile.LABEL.ToLower()) && p.ID != userprofile.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), "Profile is duplicated");

                var founduserprofile = unitOfWork.MA_USER_PROFILERepository.All().FirstOrDefault(p => p.ID == userprofile.ID);
                if (founduserprofile == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {

                    founduserprofile.ID = userprofile.ID;
                    founduserprofile.LABEL = userprofile.LABEL;
                    founduserprofile.ISACTIVE = userprofile.ISACTIVE;

                    unitOfWork.Commit();

                }
            }

            return userprofile;
        }
コード例 #28
0
ファイル: DealBusiness.cs プロジェクト: Theeranit/DealMarker
        public DA_TRN Update(SessionInfo sessioninfo, DA_TRN trn)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var foundData = unitOfWork.DA_TRNRepository.All().FirstOrDefault(p => p.ID == trn.ID);
                if (foundData == null)
                    throw this.CreateException(new Exception(), "Data not found!");
                else
                {
                    foundData.LOG.MODIFYBYUSERID = trn.LOG.MODIFYBYUSERID;
                    foundData.LOG.MODIFYDATE = trn.LOG.MODIFYDATE;
                    foundData.EXT_DEAL_NO = trn.EXT_DEAL_NO;
                    foundData.EXT_PORTFOLIO = trn.EXT_PORTFOLIO;
                    foundData.STATUS_ID = trn.STATUS_ID;

                    unitOfWork.Commit();

                }
            }

            return trn;
        }
コード例 #29
0
        public MA_PROFILE_FUNCTIONAL UpdateProfileFunction(SessionInfo sessioninfo, MA_PROFILE_FUNCTIONAL profilefunction)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PROFILE_FUNCTIONALRepository.GetAll().FirstOrDefault(p => p.USER_PROFILE_ID == profilefunction.USER_PROFILE_ID && p.FUNCTIONAL_ID == profilefunction.FUNCTIONAL_ID && p.ID != profilefunction.ID);
                if (checkDuplicate != null)
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);

                var foundprofilefunction = unitOfWork.MA_PROFILE_FUNCTIONALRepository.All().FirstOrDefault(p => p.ID == profilefunction.ID);
                if (foundprofilefunction == null)
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                else
                {

                    foundprofilefunction.ID = profilefunction.ID;
                    foundprofilefunction.ISAPPROVABLE = profilefunction.ISAPPROVABLE;
                    foundprofilefunction.ISREADABLE = profilefunction.ISREADABLE;
                    foundprofilefunction.ISWRITABLE = profilefunction.ISWRITABLE;
                    foundprofilefunction.USER_PROFILE_ID = profilefunction.USER_PROFILE_ID;
                    foundprofilefunction.FUNCTIONAL_ID = profilefunction.FUNCTIONAL_ID;
                    unitOfWork.Commit();

                }
            }

            return profilefunction;
        }
コード例 #30
0
ファイル: DealBusiness.cs プロジェクト: Theeranit/DealMarker
        public string SubmitSwapDeal(SessionInfo sessioninfo
										, DA_TRN trn
										, string strOverApprover
										, string strOverComment
										, string strProductId)
        {
            //trn.STATUS_ID = Guid.Parse("9161ed18-1298-44fa-ba7d-34522cb40d66");
            //trn.INT_DEAL_NO = GetNewDealNo(sessioninfo.Process.CurrentDate);

            //StaticDataBusiness _staticdataBusiness = new StaticDataBusiness();
            //trn.KK_PCCF = _staticdataBusiness.GetSwapKKPCCF(sessioninfo, trn);
            //trn.KK_CONTRIBUTE = trn.FIRST.NOTIONAL * trn.KK_PCCF / 100;
            //trn.BOT_PCCF = _staticdataBusiness.GetSwapBOTPCCF(sessioninfo, trn);
            //trn.BOT_CONTRIBUTE = trn.FIRST.NOTIONAL * trn.BOT_PCCF / 100;
            LookupBusiness _lookupBusiness = new LookupBusiness();
            if (!String.IsNullOrEmpty(strOverApprover))
            {
                trn.OVER_APPROVER = strOverApprover;
                trn.OVER_COMMENT = strOverComment;
            }

            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                Guid guTemp;
                if (Guid.TryParse(strProductId, out guTemp))
                {
                    var foundDeal = unitOfWork.DA_TRNRepository.All().FirstOrDefault(p => p.ID == guTemp);
                    if (foundDeal == null)
                        throw this.CreateException(new Exception(), "Data not found!");
                    else
                    {
                        foundDeal.STATUS_ID = _lookupBusiness.GetStatusAll().FirstOrDefault(p => p.LABEL == StatusCode.CANCELLED.ToString()).ID;
                        foundDeal.REMARK = trn.REMARK;
                    }
                }
                trn.REMARK = null;
                if (trn.INT_DEAL_NO == null)
                    trn.INT_DEAL_NO = GetNewDealNo(sessioninfo.Process.CurrentDate);
                unitOfWork.DA_TRNRepository.Add(trn);
                unitOfWork.Commit();
            }
            return trn.INT_DEAL_NO;
        }