public static List <int> UpdateUserSpinStatus(int reward) { //define empty int list List <int> couponList = new List <int>(); //if reward count is greater than 0 then loop number of reward count and add coupon code (if 2 rewards then 2 coupons) if (reward > 0) { //first add number of points into point table/in here number of rewards are multiplied by 5 (1 reward coupon = 5 points) mgtPoint.Add(userId, reward * 5); //retive current points object fro the user clsPoint points = mgtPoint.GetPoints(userId); for (int i = 0; i < reward; i++) { //create coupon object clsCoupon coupon = new clsCoupon(); coupon.PointId = points.Id; coupon.Code = GenerateRandomNo(); //save coupon mgtCoupon.Add(coupon); //send coupon mail mgtMails.SendCouponCode(userId, coupon.Code); //add each coupon code created into int list couponList.Add(coupon.Code); } } //update spinned status for the user mgtUSer.UpdateUserSpinStatus(userId); //return coupon list return(couponList); }
private void GenerateCoupon(int userId) { clsPoint points = mgtPoint.GetPoints(userId); if (points.Points >= 5) { clsCoupon coupon = new clsCoupon(); coupon.PointId = points.Id; coupon.Code = GenerateRandomNo(); mgtCoupon.Add(coupon); mgtMails.SendCouponCode(userId, coupon.Code); } }
public static void Update(clsCoupon coupon) { try { SqlConnection con = new SqlConnection(App.GetDBCon()); SqlCommand cmd = new SqlCommand("sp_Coupon_Update", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("CouponId", coupon.Code); cmd.Parameters.AddWithValue("PointId", coupon.PointId); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } catch (Exception) { throw; } }