示例#1
0
        /// <summary>
        /// Method to insert the In-Kind Activities from the Parent Portal
        /// </summary>
        /// <param name="inkindTransList"></param>
        /// <returns></returns>
        public bool InsertParentParticipation(List <InKindTransactions> inkindTransList)
        {
            bool isResult     = false;
            int  returnResult = 0;

            try
            {
                //List<InKindTransactions> tranList = new List<InKindTransactions>();
                inkindTransList = SetActivityAmtForParent(inkindTransList);
                if (inkindTransList != null && inkindTransList.Count() > 0)
                {
                    foreach (var item in inkindTransList)
                    {
                        returnResult = new InKindData().InsertInkindTransactions(item);
                    }
                }

                isResult = (returnResult == 1);
            }
            catch (Exception ex)
            {
                clsError.WriteException(ex);
            }
            return(isResult);
        }
示例#2
0
        /// <summary>
        /// Method to set the Activity Amount for Parent
        /// </summary>
        /// <param name="transactionsList"></param>
        /// <returns>List<InKindTransactions></returns>
        public List <InKindTransactions> SetActivityAmtForParent(List <InKindTransactions> transactionsList)
        {
            //List<InKindTransactions> transList = new List<InKindTransactions>();
            //transList = transactionsList;

            try
            {
                Inkind       inkind  = new Inkind();
                StaffDetails details = StaffDetails.GetInstance();
                inkind = new InKindData().GetInkindActivities(details);

                if (inkind.InkindActivityList.Count() > 0 && transactionsList != null && transactionsList.Count() > 0)
                {
                    foreach (var item in transactionsList)
                    {
                        item.ParentID = EncryptDecrypt.Decrypt64(item.ParentID);
                        string actvitytype        = "";
                        string ActivityAmountRate = "";

                        if (item.ActivityID > 0)
                        {
                            actvitytype = inkind.InkindActivityList.Where(x => x.ActivityCode == item.ActivityID.ToString()).Select(x => x.ActivityType).FirstOrDefault();
                        }

                        if (actvitytype == "2" || item.ActivityID == 0)
                        {
                            actvitytype = (actvitytype == "") ? (item.Hours > 0 || item.Minutes > 0) ? "2" : (item.MilesDriven > 0) ? "1" : actvitytype : actvitytype;

                            item.ActivityID    = inkind.InkindActivityList.Where(x => x.ActivityType == actvitytype).Select(x => Convert.ToInt32(x.ActivityCode)).FirstOrDefault();
                            ActivityAmountRate = inkind.InkindActivityList.Where(x => x.ActivityCode == item.ActivityID.ToString()).Select(x => x.ActivityAmountRate).FirstOrDefault();
                        }

                        else
                        {
                            ActivityAmountRate = inkind.InkindActivityList.Where(x => x.ActivityCode == item.ActivityID.ToString()).Select(x => x.ActivityAmountRate).FirstOrDefault();
                        }


                        if (item.Hours > 0 || item.Minutes > 0)
                        {
                            // var InKindAmount1 = Convert.ToDouble(ActivityAmountRate) * (4 + (45 / 60));//46.56
                            item.InKindAmount = Convert.ToDecimal((Convert.ToDouble(ActivityAmountRate) * (item.Hours + (item.Minutes / 60))).ToString("F", CultureInfo.InvariantCulture));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                clsError.WriteException(ex);
            }
            return(transactionsList);
        }