Пример #1
0
        public MA_PRODUCT UpdateProduct(SessionInfo sessioninfo, MA_PRODUCT product)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PRODUCTRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(product.LABEL.ToLower()) && p.ID != product.ID);
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                var foundProduct = unitOfWork.MA_PRODUCTRepository.All().FirstOrDefault(p => p.ID == product.ID);
                if (foundProduct == null)
                {
                    throw this.CreateException(new Exception(), Messages.DATA_NOT_FOUND);
                }
                else
                {
                    foundProduct.ID       = product.ID;
                    foundProduct.LABEL    = product.LABEL;
                    foundProduct.ISACTIVE = product.ISACTIVE;

                    unitOfWork.Commit();
                }
            }

            return(product);
        }
Пример #2
0
        public MA_PRODUCT GetProductByID(SessionInfo sessioninfo, Guid guID)
        {
            MA_PRODUCT prod = null;

            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                prod = unitOfWork.MA_PRODUCTRepository.GetAll().FirstOrDefault(p => p.ID == guID);
            }
            return(prod);
        }
Пример #3
0
        public MA_PRODUCT GetProductByUsercode(string usercode)
        {
            MA_PRODUCT prod = null;

            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                prod = unitOfWork.MA_PRODUCTRepository.GetAll().FirstOrDefault(t => t.LABEL.Contains(usercode));
            }
            return(prod);
        }
Пример #4
0
 public static object UpdateProduct(SessionInfo sessioninfo, MA_PRODUCT record)
 {
     try
     {
         LookupBusiness _lookupbusiness = new LookupBusiness();
         record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE.Value ? false : true;
         record.LABEL    = record.LABEL;
         var updated = _lookupbusiness.UpdateProduct(sessioninfo, record);
         return(new { Result = "OK" });
     }
     catch (Exception ex)
     {
         return(new { Result = "ERROR", Message = ex.Message });
     }
 }
Пример #5
0
        public MA_PRODUCT CreateProduct(SessionInfo sessioninfo, MA_PRODUCT product)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var checkDuplicate = unitOfWork.MA_PRODUCTRepository.GetAll().FirstOrDefault(p => p.LABEL.ToLower().Equals(product.LABEL.ToLower()));
                if (checkDuplicate != null)
                {
                    throw this.CreateException(new Exception(), Messages.DUPLICATE_DATA);
                }

                unitOfWork.MA_PRODUCTRepository.Add(product);
                unitOfWork.Commit();
            }

            return(product);
        }
Пример #6
0
        //public static object CreateBondInstruments(SessionInfo sessioninfo, MA_INSTRUMENT record)
        //{
        //    try
        //    {
        //        InstrumentBusiness _instrumentBusiness = new InstrumentBusiness();
        //        ILookupValuesRepository _lookupvaluesRepository = RepositorySesssion.GetRepository();

        //        record.ID = Guid.NewGuid();
        //        record.ISACTIVE = record.ISACTIVE == null || !record.ISACTIVE ? false : true;
        //        record.PRODUCT_ID = _lookupvaluesRepository.ProductRepository.GetByLabel(ProductCode.BOND.ToString()).ID;
        //        record.LOG.INSERTDATE = DateTime.Now;
        //        record.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;

        //        var addedRecord = _instrumentBusiness.Create(sessioninfo, record);
        //        return new { Result = "OK", Record = addedRecord };
        //    }
        //    catch (Exception ex)
        //    {
        //        return new { Result = "ERROR", Message = ex.Message };
        //    }
        //}

        public static object Update(SessionInfo sessioninfo, MA_INSTRUMENT record)
        {
            try
            {
                InstrumentBusiness      _instrumentBusiness     = new InstrumentBusiness();
                ILookupValuesRepository _lookupvaluesRepository = RepositorySesssion.GetRepository();
                MA_PRODUCT product = _lookupvaluesRepository.ProductRepository.GetByID(record.PRODUCT_ID);

                ProductCode eProduct = (ProductCode)Enum.Parse(typeof(ProductCode), product.LABEL.Replace(" ", string.Empty));

                record.LABEL      = record.LABEL.ToUpper();
                record.ISACTIVE   = record.ISACTIVE == null || !record.ISACTIVE ? false : true;
                record.FLAG_FIXED = record.FLAG_FIXED == null || !record.FLAG_FIXED.Value ? false : true;

                if (eProduct != ProductCode.BOND)
                {
                    record.INS_MKT             = null;
                    record.ISSUER              = null;
                    record.LOT_SIZE            = null;
                    record.COUPON              = null;
                    record.MATURITY_DATE       = null;
                    record.CAL_METHOD          = null;
                    record.FLAG_FIXED          = null;
                    record.COUPON_FREQ_TYPE_ID = null;
                }

                record.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                record.LOG.MODIFYDATE     = DateTime.Now;
                var addedRecord = _instrumentBusiness.Update(sessioninfo, record, eProduct);
                return(new { Result = "OK" });
            }
            catch (Exception ex)
            {
                return(new { Result = "ERROR", Message = ex.Message });
            }
        }
Пример #7
0
        public decimal?GetPCCF(SessionInfo sessioninfo, DA_TRN trn)
        {
            try
            {
                decimal?           decPCCF         = null;
                LookupBusiness     _lookupBusiness = new LookupBusiness();
                PCCFConfigBusiness _pccfBusiness   = new PCCFConfigBusiness();

                MA_PRODUCT  product  = _lookupBusiness.GetProductByID(sessioninfo, trn.PRODUCT_ID.Value);
                ProductCode nProduct = (ProductCode)Enum.Parse(typeof(ProductCode), product.LABEL.Replace(" ", string.Empty));

                MA_PCCF pccf = _pccfBusiness.ValidatePCCFConfig(sessioninfo, trn);

                //if (pccf == null)
                //    throw this.CreateException(new Exception(), "Cannot find PCCF for transaction #" + trn.EXT_DEAL_NO);

                if (nProduct == ProductCode.BOND || nProduct == ProductCode.REPO)
                {
                    InstrumentBusiness _instrumentBusiness = new InstrumentBusiness();

                    //------Check whether seleted bond can be used.---------
                    MA_INSTRUMENT ins = _instrumentBusiness.GetByID(sessioninfo, trn.INSTRUMENT_ID.Value);

                    if (trn.MATURITY_DATE >= ins.MATURITY_DATE)
                    {
                        throw this.CreateException(new Exception(), "Settlement date cannot be equal or after bond maturity date.");
                    }

                    if (pccf == null)
                    {
                        throw this.CreateException(new Exception(), "Selected instrument cannot be used.");
                    }
                    //-------------------------------------------------------

                    decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetYearBucket(trn.START_DATE.Value, ins.MATURITY_DATE.Value));
                }
                else
                {
                    if (pccf == null)
                    {
                        throw this.CreateException(new Exception(), "PCCF is not defined in the system." + "RF");
                    }

                    if (nProduct == ProductCode.SWAP)
                    {
                        decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetYearBucket(trn.START_DATE.Value, trn.MATURITY_DATE.Value));
                    }
                    else if (nProduct == ProductCode.FXSPOT)
                    {
                        decPCCF = pccf.DEFAULT;
                    }
                    else if (nProduct == ProductCode.FXFORWARD)
                    {
                        decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetMonthBucket(trn.START_DATE.Value, trn.MATURITY_DATE.Value));
                    }
                    else if (nProduct == ProductCode.FXSWAP)
                    {
                        if (trn.TRADE_DATE == trn.MATURITY_DATE)
                        {
                            decPCCF = pccf.C0D;
                        }
                        else if (trn.MATURITY_DATE < trn.SPOT_DATE)
                        {
                            decPCCF = pccf.C1D;
                        }
                        else if (trn.MATURITY_DATE == trn.SPOT_DATE)
                        {
                            decPCCF = pccf.DEFAULT;
                        }
                        else
                        {
                            decPCCF = LimitHelper.GetPCCFValue(pccf, LimitHelper.GetMonthBucket(trn.START_DATE.Value, trn.MATURITY_DATE.Value));
                        }
                    }
                }

                return(decPCCF);
            }
            catch (Exception ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Пример #8
0
 public static object Update(MA_PRODUCT record)
 {
     return(LookupUIP.UpdateProduct(SessionInfo, record));
 }