Beispiel #1
0
        // METHOD ID: M_0000007
        public bool UpdateFundECommerceBonusByMemberSource(string MemberID)
        {
            bool   ret = false;
            double ecommerceBonusAmount    = 0;
            double ecommerceBonusNewAmount = 0;
            string fundName = "ECommerceBonus";

            using (var tr = db.Database.BeginTransaction())
            {
                try
                {
                    var fundMaster      = db.tbl_company_funds_master.Where(x => x.FundName == fundName).FirstOrDefault();
                    var memberBonusTemp = db.tbl_member_bonus_temp.Where(x => x.MemberID == MemberID).FirstOrDefault();

                    if (fundMaster == null)
                    {
                        fundMaster = new tbl_company_funds_master()
                        {
                            FundName = fundName
                        };
                        db.tbl_company_funds_master.Add(fundMaster);
                        db.SaveChanges();
                    }

                    if (fundMaster != null && memberBonusTemp != null)
                    {
                        var currentTempECommerceBonus = memberBonusTemp.ECommerceBonusBalance;

                        if (currentTempECommerceBonus > 0)
                        {
                            ecommerceBonusAmount    = (double)currentTempECommerceBonus * (KDMBonusSlabs.RoyalClubBonusPercentage / (float)100);
                            ecommerceBonusNewAmount = (double)fundMaster.FundAmount + ecommerceBonusAmount;

                            #region Member Bonus History Create
                            tbl_company_funds_history tbl = new tbl_company_funds_history();
                            tbl.FundName        = KDMBonusConstants.ECommerce;
                            tbl.FundAmount      = Convert.ToDecimal(ecommerceBonusAmount);
                            tbl.FundTotalAmount = Convert.ToDecimal(ecommerceBonusNewAmount);
                            tbl.FundUnitAmount  = KDMBonusSlabs.ECommerceBonusPercentage + "%";
                            tbl.PVUsed          = 0;
                            tbl.PVUnit          = 0;
                            tbl.FundFrom        = KDMFundFrom.Member;
                            tbl.FundFromID      = MemberID.ToString();
                            db.tbl_company_funds_history.Add(tbl);
                            #endregion

                            memberBonusTemp.ECommerceBonusBalance = 0;

                            fundMaster.FundAmount = Convert.ToDecimal(ecommerceBonusNewAmount);

                            db.SaveChanges();
                            tr.Commit();

                            ret = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "[M_0000007] [ERROR]");
                    tr.Rollback();
                }
            }

            return(ret);
        }
Beispiel #2
0
        // METHOD ID: M_0000003
        public bool UpdateFundMonthlyRoyalityBonusByMemberSource(string MemberID)
        {
            bool   ret = false;
            double monthlyRoyalityBonusAmount    = 0;
            double monthlyRoyalityBonusPVLeft    = 0;
            double monthlyRoyalityBonusNewAmount = 0;

            int   totalNoOfPV = 0;
            Int64 totalPVUsed = 0;

            string fundName = "MonthlyRoyaltyBonus";

            using (var tr = db.Database.BeginTransaction())
            {
                try
                {
                    var fundMaster      = db.tbl_company_funds_master.Where(x => x.FundName == fundName).FirstOrDefault();
                    var memberBonusTemp = db.tbl_member_bonus_temp.Where(x => x.MemberID == MemberID).FirstOrDefault();

                    if (fundMaster == null)
                    {
                        fundMaster = new tbl_company_funds_master()
                        {
                            FundName = "MonthlyRoyaltyBonus"
                        };
                        db.tbl_company_funds_master.Add(fundMaster);
                        db.SaveChanges();
                    }

                    if (fundMaster != null && memberBonusTemp != null)
                    {
                        var currentTempMonthlyRoyalityBonus = memberBonusTemp.MonthlyRoyalityBonusBalance;

                        if (currentTempMonthlyRoyalityBonus >= KDMBonusSlabs.PVForMonthlyRoyaltyBonus)
                        {
                            totalNoOfPV = (int)(currentTempMonthlyRoyalityBonus / KDMBonusSlabs.PVForMonthlyRoyaltyBonus);
                            totalPVUsed = totalNoOfPV * KDMBonusSlabs.PVForMonthlyRoyaltyBonus;
                            monthlyRoyalityBonusAmount = totalNoOfPV * KDMBonusSlabs.MonthlyRoyaltyBonus;
                            monthlyRoyalityBonusPVLeft = (double)(currentTempMonthlyRoyalityBonus - totalPVUsed);

                            monthlyRoyalityBonusNewAmount = (double)fundMaster.FundAmount + monthlyRoyalityBonusAmount;

                            #region Member Bonus History Create
                            tbl_company_funds_history tbl = new tbl_company_funds_history();
                            tbl.FundName        = KDMBonusConstants.MonthlyRoyalty;
                            tbl.FundAmount      = Convert.ToDecimal(monthlyRoyalityBonusAmount);
                            tbl.FundTotalAmount = Convert.ToDecimal(monthlyRoyalityBonusNewAmount);
                            tbl.FundUnitAmount  = KDMBonusSlabs.MonthlyRoyaltyBonus.ToString();
                            tbl.PVUsed          = totalPVUsed;
                            tbl.PVUnit          = KDMBonusSlabs.PVForMonthlyRoyaltyBonus;
                            tbl.FundFrom        = KDMFundFrom.Member;
                            tbl.FundFromID      = MemberID.ToString();
                            db.tbl_company_funds_history.Add(tbl);
                            #endregion

                            memberBonusTemp.MonthlyRoyalityBonusBalance = Convert.ToDecimal(monthlyRoyalityBonusPVLeft);

                            fundMaster.FundAmount = Convert.ToDecimal(monthlyRoyalityBonusNewAmount);

                            db.SaveChanges();
                            tr.Commit();

                            ret = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "[M_0000003] [ERROR]");
                    tr.Rollback();
                }
            }

            return(ret);
        }