Пример #1
0
        public EntityResult <BLL_Deal> SaveDeal(BLL_Deal entity)
        {
            bool locked = false;
            EntityResult <BLL_Deal> result;

            try
            {
                TblDeal tblDeal = _tblDealRepository.Get(d => d.Dealnum == entity.Dealnum, d => d.TbDealPipeline);
                if (tblDeal == null)
                {
                    throw new NotFoundAPIException($"Deal number '{entity.Dealnum}' is not available in database.");
                }

                locked = Lock(entity.Dealnum);
                OnApplyChanges(tblDeal, entity);
                _tblDealRepository.Save(tblDeal);
                UpdateReasonfordecline(entity);
                result = GetDeal(entity.Dealnum);
                result.Data.Add(new Information(entity.Dealname, "Deal Was Saved."));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (locked)
                {
                    Unlock(entity.Dealnum);
                }
            }
            return(result);
        }
Пример #2
0
        private void OnApplyChanges(TblDeal currentDeal, BLL_Deal changedEntity)
        {
            currentDeal.Dealname = changedEntity.Dealname;
            currentDeal.Status   = changedEntity.Status;
            currentDeal.Targetdt = changedEntity.Targetdt;
            currentDeal.Uw1      = changedEntity.Uw1;
            currentDeal.Uw2      = changedEntity.Uw2;
            currentDeal.Modeller = changedEntity.Modeller;
            currentDeal.Act1     = changedEntity.Act1;
            currentDeal.TbDealPipeline.ModelPriority = changedEntity.ModelPriority;
            currentDeal.TbDealPipeline.Ta            = changedEntity.Ta;
            currentDeal.Cpartynum      = changedEntity.Cedant;
            currentDeal.Cpartylocation = changedEntity.CedentLocation;

            // Defaulting based on user story - GRS-522
            currentDeal.Riskcatagory = RiskCategoryType.TraditionalRisk;
            currentDeal.Liabtype     = LiabilityType.PropertyAndCasualty;
            currentDeal.Busclass     = BusinessClassCode.Others; // defaulting to class code 10 = Others

            // Resetting Business Class Code based on 1st level exposure selection by Users on UI screen
            if (changedEntity.Exposuretype == 1125 || changedEntity.Exposuretype == 1126 || changedEntity.Exposuretype == 1128 || changedEntity.Exposuretype == 5916 || changedEntity.Exposuretype == 5922)
            {
                currentDeal.Busclass = BusinessClassCode.Casualty;  // Casualty
            }
            else if (changedEntity.Exposuretype == 5795 || changedEntity.Exposuretype == 5827)
            {
                currentDeal.Busclass = BusinessClassCode.Property;  // Property
            }
            //return true;
        }
        private static Mock <ITblDealRepository> SetupTblDealRepository(bool isNegative)
        {
            Mock <ITblDealRepository> tblDealRepository = new Mock <ITblDealRepository>();

            var expectedTbDealPipeline = new TbDealPipeline()
            {
                DealNum       = 101,
                ModelPriority = 2,
                Ta            = 2
            };

            var expectedTblDeal = new TblDeal()
            {
                Dealnum        = 101,
                Dealname       = "Test Deal",
                Status         = 3,
                Contractnum    = 100981,
                Inceptdate     = Convert.ToDateTime(DateTime.Now.AddYears(-10).ToString("MM-dd-yyyy")),
                TbDealPipeline = expectedTbDealPipeline
            };

            tblDealRepository.Setup(p => p.Get(It.IsAny <Expression <Func <TblDeal, bool> > >(), It.IsAny <Expression <Func <TblDeal, object> > >())).Returns(isNegative ? null : expectedTblDeal);
            tblDealRepository.Setup(p => p.Save(It.IsAny <TblDeal>(), false));

            return(tblDealRepository);
        }