Exemple #1
0
        public MA_CSA_AGREEMENT CreateCSA(SessionInfo sessioninfo, MA_CSA_AGREEMENT record)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_CSA_AGREEMENTRepository.All().FirstOrDefault(p => p.ID == record.ID);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), "Data is duplicated");
                }

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

            return(record);
        }
Exemple #2
0
        public static object UpdateCSA(SessionInfo sessioninfo, MA_CSA_AGREEMENT record)
        {
            try
            {
                CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();

                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;

                var updateRecord = _counterpartyBusiness.UpdateCSA(sessioninfo, record);

                return(new { Result = "OK", Record = new CSAAgreementModel {
                                 ID = updateRecord.ID, CSA_TYPE_ID = updateRecord.CSA_TYPE_ID, ISACTIVE = updateRecord.ISACTIVE
                             } });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Exemple #3
0
        public MA_CSA_AGREEMENT UpdateCSA(SessionInfo sessioninfo, MA_CSA_AGREEMENT record)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var foundData = unitOfWork.MA_CSA_AGREEMENTRepository.All().FirstOrDefault(p => p.ID == record.ID);
                if (foundData == null)
                {
                    throw this.CreateException(new Exception(), "Data not found!");
                }
                else
                {
                    foundData.CSA_TYPE_ID        = record.CSA_TYPE_ID;
                    foundData.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                    foundData.LOG.MODIFYDATE     = DateTime.Now;
                    foundData.ISACTIVE           = record.ISACTIVE;

                    unitOfWork.Commit();
                }
            }

            return(record);
        }
Exemple #4
0
        public MA_PCCF ValidatePCCFConfig(SessionInfo sessioninfo, DA_TRN record)
        {
            MA_PCCF val = null;
            bool    blnResult;

            //enter conditions
            LoggingHelper.Debug("Begin validate PCCF from config");
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var props   = record.GetType().GetProperties();
                var configs = unitOfWork.MA_PCCF_CONFIGRepository.GetAll()
                              .Where(p => p.PRODUCT_ID.Equals(record.PRODUCT_ID))
                              .OrderBy(p => p.PRIORITY);

                //bool isBond = string.Compare(unitOfWork.MA_PRODUCTRepository.GetById(record.PRODUCT_ID.Value).LABEL, ProductCode.BOND.ToString(), true) == 0;

                if (configs != null)
                {
                    List <bool> ismatchs = new List <bool>();
                    object      obj;
                    foreach (MA_PCCF_CONFIG p in configs.ToList())
                    {
                        ismatchs.Clear();
                        blnResult = false;

                        //List<MA_CONFIG_ATTRIBUTE> atts = unitOfWork.MA_CONFIG_ATTRIBUTERepository.All().Where(t => t.PCCF_CONFIG_ID == p.ID && t.ISACTIVE == true).ToList() ;

                        foreach (MA_CONFIG_ATTRIBUTE ca in p.MA_CONFIG_ATTRIBUTE.Where(t => t.ISACTIVE == true).ToList())
                        {
                            //Fix for Tables
                            switch (ca.TABLE)
                            {
                            case "DA_TRN":
                                var sel = props.FirstOrDefault(t => t.Name.Equals(ca.ATTRIBUTE));
                                if (sel != null)
                                {
                                    if (sel.GetValue(record, null).GetType() == typeof(Guid))
                                    {
                                        switch (ca.ATTRIBUTE)
                                        {
                                        //Fix for fields
                                        case "INSTRUMENT_ID":
                                            obj = new MA_INSTRUMENT();
                                            obj = unitOfWork.MA_INSTRUMENTRepository.GetByIDWithOutInclude(new Guid(sel.GetValue(record, null).ToString()));

                                            blnResult = ((MA_INSTRUMENT)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                            //ismatchs.Add(blnResult);

                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                    else if (sel.GetValue(record, null).GetType() == typeof(Boolean))
                                    {
                                        blnResult = sel.GetValue(record, null).Equals(ca.VALUE == "0" ? false : true);    // ismatchs.Add(fsel.GetValue(record.FIRST, null).Equals(ca.VALUE=="0" ? false : true));
                                    }
                                    else
                                    {
                                        blnResult = sel.GetValue(record, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                        //ismatchs.Add(blnResult);
                                    }
                                }
                                break;

                            case "BOND_MARKET":
                                MA_INSTRUMENT insMkt = unitOfWork.MA_INSTRUMENTRepository.GetByIDWithInsMarket(record.INSTRUMENT_ID.Value);

                                if (insMkt.MA_BOND_MARKET != null)
                                {
                                    blnResult = insMkt.MA_BOND_MARKET.LABEL.Equals(ca.VALUE);
                                    //ismatchs.Add(blnResult);
                                }
                                //else
                                //ismatchs.Add(false);

                                break;

                            case "FIRST":
                                var fsel = record.FIRST.GetType().GetProperties().FirstOrDefault(f => f.Name.Equals(ca.ATTRIBUTE));
                                if (fsel != null)
                                {
                                    if (fsel.GetValue(record.FIRST, null) != null)
                                    {
                                        if (fsel.GetValue(record.FIRST, null).GetType() == typeof(Guid))
                                        {
                                            switch (ca.ATTRIBUTE)
                                            {
                                            //Fix for fields
                                            case "CCY_ID":
                                                obj = new MA_CURRENCY();
                                                obj = unitOfWork.MA_CURRENCYRepository.GetByID(new Guid(fsel.GetValue(record.FIRST, null).ToString()));

                                                blnResult = ((MA_CURRENCY)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                                //ismatchs.Add();

                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        else if (fsel.GetValue(record.FIRST, null).GetType() == typeof(Boolean))
                                        {
                                            blnResult = fsel.GetValue(record.FIRST, null).Equals(ca.VALUE == "0" ? false : true);    // ismatchs.Add(fsel.GetValue(record.FIRST, null).Equals(ca.VALUE=="0" ? false : true));
                                        }
                                        else
                                        {
                                            blnResult = fsel.GetValue(record.FIRST, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);     //ismatchs.Add(fsel.GetValue(record.FIRST, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase));
                                        }
                                    }
                                    //else ismatchs.Add(false);
                                }
                                break;

                            case "SECOND":
                                //var secprop = props.FirstOrDefault(f => f.Name.Equals("SECOND"));
                                var ssel = record.SECOND.GetType().GetProperties().FirstOrDefault(f => f.Name.Equals(ca.ATTRIBUTE));
                                if (ssel != null)
                                {
                                    if (ssel.GetValue(record.SECOND, null) != null)
                                    {
                                        if (ssel.GetValue(record.SECOND, null).GetType() == typeof(Guid))
                                        {
                                            switch (ca.ATTRIBUTE)
                                            {
                                            //Fix for fields
                                            case "CCY_ID":
                                                obj = new MA_CURRENCY();
                                                obj = unitOfWork.MA_CURRENCYRepository.GetByID(new Guid(ssel.GetValue(record.SECOND, null).ToString()));

                                                blnResult = ((MA_CURRENCY)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);
                                                //ismatchs.Add(((MA_CURRENCY)obj).LABEL.Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase));

                                                break;

                                            default:
                                                break;
                                            }
                                        }
                                        else if (ssel.GetValue(record.SECOND, null).GetType() == typeof(Boolean))
                                        {
                                            blnResult = ssel.GetValue(record.SECOND, null).Equals(ca.VALUE == "0" ? false : true);    // ismatchs.Add(ssel.GetValue(record.SECOND, null).Equals(ca.VALUE == "0" ? false : true));
                                        }
                                        else
                                        {
                                            blnResult = ssel.GetValue(record.SECOND, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase);    // ismatchs.Add(ssel.GetValue(record.SECOND, null).ToString().Equals(ca.VALUE, StringComparison.CurrentCultureIgnoreCase));
                                        }
                                    }
                                    //else ismatchs.Add(false);
                                }
                                break;

                            case "COUNTERPARTY":
                                MA_COUTERPARTY ctpy = unitOfWork.MA_COUTERPARTYRepository.GetAll().FirstOrDefault(z => z.ID == record.CTPY_ID);

                                switch (ca.ATTRIBUTE)
                                {
                                case "SNAME":
                                    blnResult = ctpy.SNAME.ToUpper() == ca.VALUE.ToUpper();

                                    break;

                                case "CSA_TYPE":

                                    MA_CSA_AGREEMENT csa = unitOfWork.MA_CSA_AGREEMENTRepository.GetAll().FirstOrDefault(y => y.ID == record.CTPY_ID);

                                    if (csa != null &&
                                        csa.MA_CSA_TYPE.LABEL.ToUpper() == ca.VALUE.ToUpper() &&
                                        csa.MA_CSA_PRODUCT.FirstOrDefault(y => y.PRODUCT_ID == record.PRODUCT_ID) != null)
                                    {
                                        blnResult = true;
                                    }
                                    //else if (csa == null && ca.VALUE == "")
                                    //    blnResult = true;
                                    else
                                    {
                                        blnResult = false;
                                    }

                                    break;

                                default:
                                    break;
                                }

                                break;
                            }

                            ismatchs.Add(blnResult);

                            //Check result -> if false then go to next config
                            if (!blnResult)
                            {
                                break;
                            }
                        }

                        if (ismatchs.Where(m => m.Equals(false)).Count() == 0)
                        {
                            val = unitOfWork.MA_PCCFRepository.GetByID(p.PCCF_ID);
                            LoggingHelper.Debug("PCCF: " + val.LABEL);
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    val = null;
                }
            }
            LoggingHelper.Debug("End validate PCCF from config");
            return(val);
        }
 public static object CreateCSA(MA_CSA_AGREEMENT record)
 {
     return(CounterpartyUIP.CreateCSA(SessionInfo, record));
 }