Пример #1
0
    public static Underwriting SaveOrUpdate(Underwriting uw, string saveby)
    {
        if (String.IsNullOrEmpty(uw.BBLE))
        {
            throw new Exception("BBLE cannot be empty");
        }
        using (UnderwritingEntity ctx = new UnderwritingEntity())
        {
            var u = ctx.Underwritings.SingleOrDefault(t => t.BBLE == uw.BBLE);
            if (u != null)
            {
                if ((int)uw.Status <= 2)
                {
                    uw.Status = Underwriting.UnderwritingStatusEnum.Processing;
                }
                uw.UpdateBy   = saveby;
                uw.UpdateDate = DateTime.Now;
                ctx.Entry(u).CurrentValues.SetValues(uw);
                EntityHelper <Underwriting> .ReferenceUpdate(ctx, u, uw);
            }
            else
            {
                uw.CreateBy   = saveby;
                uw.CreateDate = DateTime.Now;
                uw.Status     = Underwriting.UnderwritingStatusEnum.NewCreated;
                ctx.Underwritings.Add(uw);
            }
            ctx.SaveChanges(saveby);

            return(u);
        }
    }
Пример #2
0
 public static Underwriting TryCreate(Underwriting underwriting)
 {
     using (UnderwritingEntity ctx = new UnderwritingEntity())
     {
         if (string.IsNullOrEmpty(underwriting.BBLE))
         {
             throw new Exception("Cannot create new underwriting without BBLE.");
         }
         var uw = ctx.Underwritings.FirstOrDefault(u => u.BBLE.Trim() == underwriting.BBLE.Trim());
         if (uw != null)
         {
             return(null);
         }
         underwriting.UpdateBy   = "System";
         underwriting.UpdateDate = DateTime.Now;
         ctx.Underwritings.Add(underwriting);
         try
         {
             ctx.SaveChanges();
         }
         catch (Exception e) {
             throw e;
         }
         return(underwriting);
     }
 }
Пример #3
0
        public Underwriting TryCreate(Underwriting underwriting)
        {
            if (underwriting == null)
            {
                return(null);
            }
            var uw = UnderwritingDAO.TryCreate(underwriting);

            return(uw);
        }
Пример #4
0
    public static UnderwritingArchived Archive(string bble, string saveBy, string note)
    {
        using (UnderwritingEntity ctx = new UnderwritingEntity())
        {
            Underwriting         underwriting = GetUnderwritingByBBLE(bble);
            UnderwritingArchived archived     = new UnderwritingArchived();
            if (underwriting != null)
            {
                archived.BBLE         = underwriting.BBLE;
                archived.ArchivedBy   = saveBy;
                archived.ArchivedDate = DateTime.Now;
                archived.ArchivedNote = note;

                archived.PropertyInfo = underwriting.PropertyInfo;
                archived.DealCosts    = underwriting.DealCosts;
                archived.RehabInfo    = underwriting.RehabInfo;
                archived.RentalInfo   = underwriting.RentalInfo;
                archived.LienInfo     = underwriting.LienInfo;
                archived.LienCosts    = underwriting.LienCosts;

                archived.CashScenario            = underwriting.CashScenario;
                archived.LoanScenario            = underwriting.LoanScenario;
                archived.FlipScenario            = underwriting.FlipScenario;
                archived.MinimumBaselineScenario = underwriting.MinimumBaselineScenario;
                archived.BestCaseScenario        = underwriting.BestCaseScenario;
                archived.RentalInfo = underwriting.RentalInfo;
                archived.Summary    = underwriting.Summary;

                archived.PropertyInfo.Id = 0;
                archived.DealCosts.Id    = 0;
                archived.RehabInfo.Id    = 0;
                archived.RentalInfo.Id   = 0;
                archived.LienInfo.Id     = 0;
                archived.LienCosts.Id    = 0;

                archived.CashScenario.Id            = 0;
                archived.LoanScenario.Id            = 0;
                archived.FlipScenario.Id            = 0;
                archived.MinimumBaselineScenario.Id = 0;
                archived.BestCaseScenario.Id        = 0;
                archived.RentalInfo.Id = 0;
                archived.Summary.Id    = 0;

                ctx.UnderwritingArchived.Add(archived);
                ctx.SaveChanges(saveBy);
            }
            return(archived);
        }
    }
Пример #5
0
    public static Underwriting Create(string BBLE, string createby)
    {
        using (UnderwritingEntity ctx = new UnderwritingEntity())
        {
            if (string.IsNullOrEmpty(BBLE))
            {
                throw new Exception("BBLE cannot be empty.");
            }
            if (string.IsNullOrEmpty(createby))
            {
                throw new Exception("Creator cannot be empty");
            }

            var underwriting = ctx.Underwritings.FirstOrDefault(u => u.BBLE == BBLE);
            if (underwriting != null)
            {
                return(underwriting);
            }
            underwriting            = new Underwriting();
            underwriting.BBLE       = BBLE;
            underwriting.CreateBy   = createby;
            underwriting.CreateDate = DateTime.Now;

            underwriting.PropertyInfo = new UnderwritingPropertyInfo();
            underwriting.DealCosts    = new UnderwritingDealCosts();
            underwriting.RehabInfo    = new UnderwritingRehabInfo();
            underwriting.RentalInfo   = new UnderwritingRentalInfo();
            underwriting.LienInfo     = new UnderwritingLienInfo();
            underwriting.LienCosts    = new UnderwritingLienCosts();

            underwriting.CashScenario            = new UnderwritingCashScenario();
            underwriting.LoanScenario            = new UnderwritingLoanScenario();
            underwriting.FlipScenario            = new UnderwritingFlipScenario();
            underwriting.MinimumBaselineScenario = new UnderwritingMinimumBaselineScenario();
            underwriting.BestCaseScenario        = new UnderwritingBestCaseScenario();
            underwriting.RentalInfo = new UnderwritingRentalInfo();
            underwriting.Summary    = new UnderwritingSummary();

            underwriting.Status = Underwriting.UnderwritingStatusEnum.NewCreated;

            ctx.Underwritings.Add(underwriting);
            ctx.SaveChanges(createby);
            return(underwriting);
        }
    }
Пример #6
0
        public OperationResult Consume(Underwriting message)
        {
            Console.WriteLine(" * Underwriting Policy * ");

            if (SagaData.Policy == null)
            {
                return(new OperationResult());
            }

            var underwritingResult = _policyMmgt.UnderwriteNewPolicy(SagaData.Policy);

            if (underwritingResult.Any())
            {
                return(new OperationResult(underwritingResult.ToArray()));
            }

            var invoice = _policyMmgt.GenerateInvoice(SagaData.Policy);

            SagaData.Invoice = invoice;

            return(new OperationResult().AddPayload(SagaData.Invoice));
        }
Пример #7
0
 public UnderwritingArchived PostArchive(Underwriting underwriting, string archiveNote, string username)
 {
     UnderwritingDAO.SaveOrUpdate(underwriting, username);
     return(UnderwritingDAO.Archive(underwriting.BBLE, username, archiveNote));
 }
Пример #8
0
 public Underwriting PostUnderwriting(Underwriting underwriting, string username)
 {
     return(UnderwritingDAO.SaveOrUpdate(underwriting, username));
 }