hasokeric
12/19/2016 - 7:56 PM

Quote.GetQuotedInfo.BASE.cs

// Main Query
var quotes =
    from    tqh in ttQuoteHed
    join    qh in Db.QuoteHed.With(LockHint.NoLock) on tqh.QuoteNum equals qh.QuoteNum
    where   tqh.Updated()
    select  new { tqh, qh };

foreach (var quoteRow in quotes)
{
    /* DateQuoted we will try to use our initial Date */
    if (quoteRow.tqh.Quoted == true)
    {
        if ( ((DateTime?)quoteRow.tqh["Date01"]).HasValue)
        {
            quoteRow.tqh.DateQuoted = (DateTime?)quoteRow.tqh["Date01"];
        }
        else
        {
            quoteRow.tqh.DateQuoted = DateTime.Now;
        }
    }
    else
    {
        quoteRow.tqh.DateQuoted = null;
    }



    /* Expiration Date Based on SOP */
    if (quoteRow.tqh.Quoted == true)
    {
        if (quoteRow.tqh.ExpectedClose.HasValue)
        {
            quoteRow.tqh.ExpirationDate = quoteRow.tqh.ExpectedClose.Value.AddDays(90);
        }
        else
        {
            quoteRow.tqh.ExpirationDate = quoteRow.tqh.DateQuoted.Value.AddDays(30);
        }
    }
    else
    {
        quoteRow.tqh.ExpirationDate = null;
    }


    /* Follow Up Date */
    if ( !quoteRow.qh.FollowUpDate.HasValue && quoteRow.tqh.Quoted == true)
    {
        quoteRow.tqh.FollowUpDate = DateTime.Now.AddDays(10);
    }
    else
    {
        quoteRow.tqh.FollowUpDate = quoteRow.qh.FollowUpDate;
    }

}