public object LoyaltyPerformance(string GroupId) { if (User.Identity.IsAuthenticated) { LoyaltyKPIs objLoyaltyKPIs = new LoyaltyKPIs(); try { string connectionString = CR.GetCustomerConnString(GroupId); objLoyaltyKPIs = LKR.GetobjLoyaltyKPIsData(GroupId, connectionString); var Sum = objLoyaltyKPIs.Redemption + objLoyaltyKPIs.Referrals + objLoyaltyKPIs.Campaigns + objLoyaltyKPIs.SMSBlastWA + objLoyaltyKPIs.NewMWPRegistration; objLoyaltyKPIs.RedemptionPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.Redemption) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.ReferralsPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.Referrals) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.CampaignsPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.Campaigns) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.SMSBlastWAPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.SMSBlastWA) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.NewMWPRegistrationPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.NewMWPRegistration) / Convert.ToDecimal(Sum)) * 100), 2); } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(new { Data = objLoyaltyKPIs, MaxJsonLength = Int32.MaxValue }); } return("Invalid Token or Expired"); }
public ActionResult LoyaltyPerformance() { var userDetails = (CustomerLoginDetail)Session["UserSession"]; LoyaltyKPIs objLoyaltyKPIs = new LoyaltyKPIs(); objLoyaltyKPIs = LKR.GetobjLoyaltyKPIsData(userDetails.GroupId, userDetails.connectionString); var Sum = objLoyaltyKPIs.Redemption + objLoyaltyKPIs.Referrals + objLoyaltyKPIs.Campaigns + objLoyaltyKPIs.SMSBlastWA + objLoyaltyKPIs.NewMWPRegistration; if (Sum != 0) { objLoyaltyKPIs.RedemptionPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.Redemption) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.ReferralsPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.Referrals) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.CampaignsPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.Campaigns) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.SMSBlastWAPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.SMSBlastWA) / Convert.ToDecimal(Sum)) * 100), 2); objLoyaltyKPIs.NewMWPRegistrationPer = Math.Round(((Convert.ToDecimal(objLoyaltyKPIs.NewMWPRegistration) / Convert.ToDecimal(Sum)) * 100), 2); } return(View(objLoyaltyKPIs)); }
public LoyaltyKPIs GetobjLoyaltyKPIsData(string GroupId, string connstr) { LoyaltyKPIs objLoyaltyKPIs = new LoyaltyKPIs(); try { using (var context = new BOTSDBContext(connstr)) { objLoyaltyKPIs = context.Database.SqlQuery <LoyaltyKPIs>("sp_BOTS_LoyaltyPerfromance @pi_GroupId, @pi_Date, @pi_LoginId, @pi_Month, @pi_Year, @pi_OutletId", new SqlParameter("@pi_GroupId", GroupId), new SqlParameter("@pi_Date", DateTime.Now.ToShortDateString()), new SqlParameter("@pi_LoginId", ""), new SqlParameter("@pi_Month", DateTime.Now.Month), new SqlParameter("@pi_Year", DateTime.Now.Year), new SqlParameter("@pi_OutletId", "")).FirstOrDefault <LoyaltyKPIs>(); } } catch (Exception ex) { newexception.AddException(ex, GroupId); } return(objLoyaltyKPIs); }