public ActionResult Thank_You_post() { if (Request.IsAuthenticated) { string s = User.Identity.Name; //checking deposit in wallet teporary folder var x = db.wallet_deposit_temp.Where(r => r.username == s).FirstOrDefault(); if (!string.IsNullOrEmpty(x.username)) { //var x1 = x.ToArray(); user_deposit_history udh = new user_deposit_history(); udh.username = s; udh.deposit_status = "Approved"; udh.deposit_date = x.deposit_date; udh.deposit_ammount = x.deposit_ammount; db.wallet_deposit_temp.Remove(x); db.deposit_history.Add(udh); //updating user wallet money var p = db.userprofiles.Where(r => r.username == s).FirstOrDefault(); p.wallet_money = p.wallet_money + x.deposit_ammount; db.Entry(p).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("myprofile", "Home")); } //updating instant refill history transection_final tf = new transection_final(); var y = db.refil_history.Where(r => r.username == s).FirstOrDefault(); tf.username = y.username; tf.status = y.status; tf.sent_date = y.sent_date; tf.send_to = y.send_to; tf.ammount = y.ammount; db.transection_finals.Add(tf); db.refil_history.Remove(y); db.SaveChanges(); } else { /*string s = "UnknowN"; * //updating instant refill history * transection_final tf = new transection_final(); * //var y = db.refil_history.Where(r => r.username == s).FirstOrDefault(); * tf.username = s; * tf.status = "Pending"; * tf.sent_date = DateTime.Now; * tf.send_to = "Instant recharge"; * tf.ammount = 0; * * db.transection_finals.Add(tf); * //db.refil_history.Remove(y); * db.SaveChanges();*/ return(RedirectToAction("myprofile", "Home")); } return(RedirectToAction("Index", "Home")); }
public ActionResult Thank_You_post() { string s; if (Request.IsAuthenticated) { s = User.Identity.Name; } else { s = "UnknowN"; } if (Request.IsAuthenticated) { //checking deposit in wallet teporary folder var x = db.wallet_deposit_temp.Where(r => r.username == s).ToList(); if (x.Count() > 0) { var x1 = x.ToArray(); user_deposit_history udh = new user_deposit_history(); udh.username = s; udh.deposit_status = "Approved"; udh.deposit_date = x1[0].deposit_date; udh.deposit_ammount = x1[0].deposit_ammount; db.deposit_history.Add(udh); db.wallet_deposit_temp.Remove(x1[0]); //updating user wallet money var p = db.userprofiles.Where(r => r.username == s).FirstOrDefault(); p.wallet_money = p.wallet_money + x1[0].deposit_ammount; db.Entry(p).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); } //updating instant refill history transection_final tf = new transection_final(); var y = db.refil_history.Where(r => r.username == s).FirstOrDefault(); tf.username = y.username; tf.status = y.status; tf.sent_date = y.sent_date; tf.send_to = y.send_to; tf.ammount = y.ammount; db.transection_finals.Add(tf); db.refil_history.Remove(y); db.SaveChanges(); } else { //updating instant refill history transection_final tf = new transection_final(); var y = db.refil_history.Where(r => r.username == s).FirstOrDefault(); tf.username = y.username; tf.status = y.status; tf.sent_date = y.sent_date; tf.send_to = y.send_to; tf.ammount = y.ammount; db.transection_finals.Add(tf); db.refil_history.Remove(y); db.SaveChanges(); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }