Exemplo n.º 1
0
        //public ActionResult SortMyPointsList()
        //{

        //    MyPointsListModel mypoints = new MyPointsListModel();
        //    if (Session["AllDetailPoints"] != null)
        //    {
        //        mypoints = (MyPointsListModel)Session["AllDetailPoints"];
        //    }
        //    else
        //    {
        //        PopulateOwnerPointDetails(mypoints);
        //        PopulateOwnerPointTypes(mypoints);
        //        PopulateOwnerPointSummary(mypoints);
        //        Session["AllDetailPoints"] = mypoints;
        //    }

        //    return PartialView("PointsList", mypoints);
        //}

        private void PopulateOwnerPointDetails(MyPointsListModel model)
        {
            //Global Detail Points listing
            model.AllDetailPoints = new List <PointModel>();

            List <PointModel> pttbl = new List <PointModel>();

            BGO.savePointsWS.MDPNTWSPortTypeClient theSavingPoints = new BGO.savePointsWS.MDPNTWSPortTypeClient();
            BGO.savePointsWS.PNTBALLISTWSInput     _elect          = new BGO.savePointsWS.PNTBALLISTWSInput();
            BGO.savePointsWS.PNTBALLISTWSResult    _electResult    = new BGO.savePointsWS.PNTBALLISTWSResult();

            bool     willbesaved   = false;
            bool     needtosave    = false;
            string   strExpireDate = null;
            DateTime thisDay       = DateTime.Today;

            int      lastDayOfMonth       = 0;
            DateTime dteFirstDayNextMonth = default(DateTime);
            DateTime messagedate          = DateTime.Now;

            dteFirstDayNextMonth = new DateTime(DateTime.Now.Year, DateTime.Now.AddMonths(1).Month, 1);
            lastDayOfMonth       = dteFirstDayNextMonth.AddDays(-1).Day;
            messagedate          = DateTime.Parse(DateTime.Now.Month.ToString() + "/" + lastDayOfMonth.ToString() + "/" + DateTime.Now.Year.ToString());

            DateTime AnnualExpEligDate = messagedate.AddMonths(2);//DateAdd(DateInterval.Month, 2, messagedate);

            //call as400 ws for savepoints accunt info
            _elect._PNTBALLISTPR              = new BGO.savePointsWS.PNTBALLISTDS();
            _elect._PNTBALLISTPR._LISTTYPE    = Constants.SavePointsListType;
            _elect._PNTBALLISTPR._OWNERNUMBER = BXGOwner.Arvact;
            _elect._PNTBALLISTPR._POINTTYPES  = Constants.SavePointsBuckets;
            _electResult = theSavingPoints.pntballistws(_elect);

            if ((_electResult._PNTBALLISTWSDI != null))
            {
                for (int x = 0; x <= (_electResult._PNTBALLISTWSDI.Length - 1); x++)
                {
                    //grid will show points details for all owners except for Expired Value sampler and sampler 24
                    if (_electResult._PNTBALLISTWSDI[x]._PROJ_ != "51" && _electResult._PNTBALLISTWSDI[x]._PROJ_ != "52")
                    {
                        PointModel ptsdtl = new PointModel();
                        strExpireDate = string.Format("{0:MM/dd/yyyy}", DateTime.Parse(_electResult._PNTBALLISTWSDI[x]._ENDDATE));

                        //Populate Results to Model
                        ptsdtl.AcctNum       = _electResult._PNTBALLISTWSDI[x]._ACCT_.Trim();
                        ptsdtl.ExpireDate    = Convert.ToDateTime(strExpireDate);
                        ptsdtl.PointBal      = Convert.ToInt32(_electResult._PNTBALLISTWSDI[x]._POINTBAL);
                        ptsdtl.Action        = _electResult._PNTBALLISTWSDI[x]._OPTIONPAID;
                        ptsdtl.PointTypeDesc = _electResult._PNTBALLISTWSDI[x]._REFCODE;

                        //TODO: Validate this logic
                        //validate owner has more the save points set
                        if (needtosave == false & DateTime.Parse(strExpireDate) >= thisDay & _electResult._PNTBALLISTWSDI[x]._OPTIONPAID == "0" & Convert.ToInt32(_electResult._PNTBALLISTWSDI[x]._POINTBAL) > 0)
                        {
                            needtosave = true;
                        }
                        else if (needtosave == false & willbesaved == false & DateTime.Parse(strExpireDate) >= thisDay & _electResult._PNTBALLISTWSDI[x]._OPTIONPAID == "1" & Convert.ToInt32(_electResult._PNTBALLISTWSDI[x]._POINTBAL) > 0)
                        {
                            willbesaved = true;
                        }

                        //pttbl.Rows.Add(tbl_row);
                        //Add to points
                        pttbl.Add(ptsdtl);
                        //model.AllPoints.AllDetailPoints.Add(ptsdtl);
                    }
                }
            }

            //override as400 message
            if (needtosave == false & willbesaved == true)
            {
                ViewBag.Message = "<p> The eligible Points in your account(s) will be automatically saved at the end of their expiration date for an additional year of use in Red, White and Blue seasons. Thank you for electing to save your Points.</p>";
                //model.Message = "<p> The eligible Points in your account(s) will be automatically saved at the end of their expiration date for an additional year of use in Red, White and Blue seasons. Thank you for electing to save your Points.</p>";
            }
            else if (needtosave == true)
            {
                ViewBag.HidePaymentInfo = false;
                //model.PaymentInformationVisible = true;
                //ViewBag.Message = BXGOwner.AnnualPointsExpiration.SavePointsMessage;
                ViewBag.Message = "<p><strong>Expiring Points Alert:</strong> You have Points in your account(s) that will expire unless you elect to save them before their expiration date. Click the Save My Points button below in order to have the eligible Points automatically save on their expiration date.</p>";
            }
            else if (needtosave == false & willbesaved == false)
            {
                ViewBag.Message = "<p>You do not currently have any Points in your account that are eligible to be saved.</p>";
                //ViewBag.PaymentInformationVisible = false;
                ViewBag.HidePaymentInfo = true;
            }

            string pointsdescval = null;


            //------------------------------------------------------
            //Fetching Owner Information from WebService OwnerWS1
            //------------------------------------------------------

            BGO.OwnerWS.AccountInfo[] accountList = null;
            List <string>             accList     = new List <string>();

            //Call to Web Service Returning AccountInfo
            accountList = OwnerService.fetchOwnerAccounts(BXGOwner.Arvact);

            //TODO: Remove this when actually connecting to WebService For now Just clone the values in StubMe out
            //accountList = (OwnerWS.AccountInfo[])BXGOwner.Accounts.Clone();

            for (int count = 0; count <= accountList.Length - 1; count++)
            {
                if (accountList[count].Proj == "51" || accountList[count].Proj == "52")
                {
                    accList.Add(accountList[count].AcctNum);
                }
            }

            foreach (BGO.OwnerWS.Point point_row in OwnerService.fetchOwnerPointsBuckets(BXGOwner.Arvact))
            {
                //remove point details for expired Value sampler and Sampler 24 owners
                bool valid = true;
                if (!object.Equals(null, accList) & accList.Count > 0)
                {
                    if (accList.Contains(point_row.AcctNum))
                    {
                        valid = false;
                    }
                }
                if (valid)
                {
                    pointsdescval = string.Empty;
                    strExpireDate = point_row.expireDate.ToString();

                    //DateTime as400ExpireDate;
                    string acct    = point_row.AcctNum;
                    int    tpoints = point_row.pointBal;

                    PointModel ptsdtl = new PointModel();

                    ptsdtl.AcctNum    = point_row.AcctNum.Trim();
                    ptsdtl.PointBal   = point_row.pointBal;
                    ptsdtl.ExpireDate = point_row.expireDate;//DateTime.Parse(strExpireDate);


                    //It’s only apply for Sampler Owners (VS and S24).
                    if ((BXGOwner.User[0].isSampler))
                    {
                        //It’s only apply for Sampler 24 Owners.
                        if ((BXGOwner.User[0].HomeProject) == "52")
                        {
                            if (point_row.pointTypeDesc == "Additional Points")
                            {
                                point_row.pointTypeDesc = "Annual";
                            }
                        }
                    }
                    ptsdtl.PointTypeDesc  = point_row.pointTypeDesc;
                    ptsdtl.PointType      = point_row.pointsType;
                    ptsdtl.NextEarnDate   = point_row.nextEarnDate;
                    ptsdtl.NextEarnAmount = point_row.nextEarnAmount;
                    ptsdtl.EarnedDate     = point_row.beginDate;


                    if (point_row.pointTypeDesc == "Annual" || point_row.pointTypeDesc == "Borrowed")
                    {
                        var foundRows = from x in pttbl.ToList()
                                        where x.PointBal == point_row.pointBal && x.ExpireDate == Convert.ToDateTime(strExpireDate) && x.AcctNum == point_row.AcctNum.Trim()
                                        select x;


                        //int i = 0;
                        // Print column 0 of each returned row.
                        foreach (var row in foundRows)//(i = 0; i < foundRows.Count(); i++)
                        {
                            if (Convert.ToDateTime(strExpireDate) >= thisDay & row.Action == "1" & point_row.pointBal <= 0)
                            {
                                ptsdtl.Action = "N/A";
                            }
                            else if ((Convert.ToDateTime(strExpireDate) >= thisDay & row.Action == "1" & point_row.pointBal > 0))
                            {
                                ptsdtl.Action = "Will be Saved";
                            }
                            else if ((Convert.ToDateTime(strExpireDate) >= thisDay & row.Action == "0" & point_row.pointBal > 0))
                            {
                                ptsdtl.Action = "Need to Save";
                            }
                            else
                            {
                                ptsdtl.Action = "N/A";
                            }
                        }
                    }
                    else
                    {
                        ptsdtl.Action = "N/A";
                    }

                    //TODO:
                    if (BXGOwner.User[0].isSampler == true)
                    //if (isSamplerOwner == true)
                    {
                        ptsdtl.Action         = "N/A";
                        ptsdtl.NextEarnDate   = "N/A";
                        ptsdtl.NextEarnAmount = "N/A";
                    }

                    model.AllDetailPoints.Add(ptsdtl);
                }
            }
        }
Exemplo n.º 2
0
        private void PopulateAcctContractInfo(MyPointsModel model)
        {
            BGO.savePointsWS.MDPNTWSPortTypeClient theSavingPoints = new BGO.savePointsWS.MDPNTWSPortTypeClient();
            BGO.savePointsWS.PNTBALLISTWSInput     _elect          = new BGO.savePointsWS.PNTBALLISTWSInput();
            BGO.savePointsWS.PNTBALLISTWSResult    _electResult    = new BGO.savePointsWS.PNTBALLISTWSResult();
            bool needtosave  = false;
            bool willbesaved = false;

            _elect._PNTBALLISTPR              = new BGO.savePointsWS.PNTBALLISTDS();
            _elect._PNTBALLISTPR._LISTTYPE    = Constants.SavePointsListType;
            _elect._PNTBALLISTPR._OWNERNUMBER = BXGOwner.Arvact;
            _elect._PNTBALLISTPR._POINTTYPES  = Constants.SavePointsBuckets;
            _electResult = theSavingPoints.pntballistws(_elect);

            if (_electResult._PNTBALLISTWSDI != null)
            {
                for (int x = 0; x <= _electResult._PNTBALLISTWSDI.Length - 1; x++)
                {
                    string strExpireDate = String.Format("{0:MM/dd/yyyy}", DateTime.Parse(_electResult._PNTBALLISTWSDI[x]._ENDDATE));

                    if (!needtosave && Convert.ToDateTime(strExpireDate) >= System.DateTime.Today && _electResult._PNTBALLISTWSDI[x]._OPTIONPAID == "0" &&
                        Convert.ToInt32(_electResult._PNTBALLISTWSDI[x]._POINTBAL) > 0)
                    {
                        needtosave = true;
                    }
                    else if (!needtosave && !willbesaved && Convert.ToDateTime(strExpireDate) >= System.DateTime.Today && _electResult._PNTBALLISTWSDI[x]._OPTIONPAID == "1" &&
                             Convert.ToInt32(_electResult._PNTBALLISTWSDI[x]._POINTBAL) > 0)
                    {
                        willbesaved = true;
                    }
                }
            }

            if (!needtosave && willbesaved)
            {
                model.Message = "<p> The eligible Points in your account(s) will be automatically saved at the end of their expiration date for an additional year of use in Red, White and Blue seasons. Thank you for electing to save your Points.</p>";
                model.HideSavePointsButton = true;
            }
            else if (needtosave)
            {
                model.HideSavePointsButton = false;
            }
            else if (!needtosave && !willbesaved)
            {
                model.Message = "<p>You do not currently have any Points in your account that are eligible to be saved.</p>";
                model.HideSavePointsButton = true;
            }

            try
            {
                //Final check for hidesavepoints button
                if (model.HomeProject == "52")
                {
                    model.HideSavePointsButton = false;
                    model.Message           = String.Empty;
                    model.HidePanelReminder = true;
                    MyPointsModel myPoints = new MyPointsModel();
                    myPoints.Message           = String.Empty;
                    myPoints.ConvertYourPoints = String.Empty;
                    if (BXGOwner.AnnualPointsExpiration.SavePointsEligible && BXGOwner.AnnualPointsExpiration.SavePointsEligible.ToString().Trim().Length > 1)
                    {
                        model.HideSavePointsButton = true;
                    }
                }
                else
                {
                    if (BXGOwner.AnnualPointsExpiration.SavePointsEligible && BXGOwner.AnnualPointsExpiration.SavePointsEligible.ToString().Trim().Length > 1)
                    {
                        model.HideSavePointsButton = false;
                    }
                }
            }
            catch (Exception ex)
            {
                model.HideSavePointsButton = true;
            }
            if (model.IsSamplerOwner)
            {
                model.HideSavePointsButton = true;
            }

            //------------------------------------------------------
            //Fetching Owner Information from WebService OwnerWS1
            //------------------------------------------------------
            BGO.OwnerWS.AccountInfo[] accountList = null;

            model.AccountInfo = new List <AccountModel>();

            //Call to Web Service Returning AccountInfo
            accountList = OwnerService.fetchOwnerAccounts(BXGOwner.Arvact);
            //TODO: Replace this with line above when actually connecting to WebService For now Just clone the values in StubMe out
            //accountList = (OwnerWS.AccountInfo[])BXGOwner.Accounts.Clone();

            for (int x = 0; x <= accountList.Length - 1; x++)
            {
                if (accountList[x].Proj != "51" & accountList[x].Proj != "52")
                {
                    DateTime strExpireDate = default(DateTime);
                    if (accountList[x].Proj == "50")
                    {
                        strExpireDate             = DateTime.ParseExact(accountList[x].Expiration, "yyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                        accountList[x].Expiration = string.Format("{0:MM/dd/yyyy}", strExpireDate);
                    }

                    //Populate Results to Model
                    AccountModel acct = new AccountModel();

                    acct.AccNo         = accountList[x].index;
                    acct.AccountNumber = accountList[x].AcctNum;
                    acct.Description   = accountList[x].projNM;
                    if (accountList[x].Expiration == "0")
                    {
                        acct.NextEarnDate = "";
                    }
                    else
                    {
                        acct.NextEarnDate = accountList[x].Expiration;
                    }

                    if (accountList[x].NextEarnAmount == "0")
                    {
                        acct.NextEarnAmount = "";
                    }
                    else
                    {
                        acct.NextEarnAmount = accountList[x].NextEarnAmount;
                    }

                    model.AccountInfo.Add(acct);
                }
            }
        }