public ActionResult Payment(PayModel model) { UserTrans us = new UserTrans(); Payments paym = new Payments(); CaseTrans ct = new CaseTrans(); var user = userManager.FindByName(User.Identity.Name); decimal totalb = repoUser.TotalBalance(user.Id); us.UserId = user.Id; us.Prize = 0; us.Loose = 0; us.PaymentId = true; us.Balance = totalb + model.Bill; repoUser.Add(us); paym.UserId = user.Id; paym.UserTransId = us.Id; paym.Price = ((model.Bill) * Convert.ToDecimal(7.42) / 1000); paym.OrderType = "Ödeme"; repoPayments.Add(paym); ct.UserTransId = us.Id; ct.Income = paym.Price; ct.Expense = 0; ct.TransType = "Bill Satış"; repoCaseTrans.Add(ct); return(RedirectToAction("AccountInfo", "Account")); }
public ActionResult Register(RegisterViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var kullanici = userManager.FindByEmail(model.Email); if (kullanici != null) { ModelState.AddModelError("", "Bu e-mail sistemde kayıtlı"); return(View(model)); } var rolemanager = IdentityTools.NewRoleManager(); ApplicationRole ar = new ApplicationRole(); ar.Name = "User"; rolemanager.Create(ar); ApplicationUser user = new ApplicationUser(); user.Name = model.Name; user.Surname = model.Surname; user.Email = model.Email; user.AccountNo = model.AccountNo; user.PhoneNumber = model.ContactNo; user.UserName = model.Username; var result = userManager.Create(user, model.Password); userManager.AddToRole(user.Id, "User"); if (result.Succeeded) {//üye olan kullanıcıya hediye 5000 bil verdim UserTrans userTrans = new UserTrans(); userTrans.UserId = user.Id; userTrans.PaymentId = true; userTrans.Prize = 5000; userTrans.Loose = 0; userTrans.Balance = 5000; repoUser.Add(userTrans); return(RedirectToAction("Login")); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error); } } return(View(model)); }
public JsonResult PaymTrans(decimal desc) { decimal trans = desc * (Convert.ToDecimal(7.42) / 1000); var user = userManager.FindByName(User.Identity.Name); UserTrans us = new UserTrans(); us.Prize = 0; us.Balance = repoUser.TotalBalance(user.Id) - desc; us.UserId = user.Id; us.Loose = 0; repoUser.Add(us); CaseTrans cs = new CaseTrans(); cs.UserTransId = us.Id; cs.Income = 0; cs.Expense = trans; cs.TransType = "Kullanıcı Ödemesi"; bool result = repoCaseTrans.Add(cs); return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { Bonus bonus = new Bonus(); var usermanager = IdentityTools.NewUserManager(); //aktif kullanici ApplicationUser appuser = usermanager.FindByName(User.Identity.Name); //aktif kullanıcının hareketler var kullanici = repoUserTrans.Get(x => x.UserId == appuser.Id); //aktip kullanıcının toplam bakiyesi decimal totalb = repoUserTrans.TotalBalance(kullanici.UserId); appuser.Counter++; usermanager.Update(appuser); if (appuser.Counter - 1 == 0) { var basiccontest = repoCon.GetAll(x => x.Level == 1); var bc = basiccontest.OrderByDescending(x => x.Date).Take(1).FirstOrDefault(); List <ContestDetails> basic = repoConDeta.GetAll(x => x.ContestId == bc.Id).ToList(); if (totalb < bc.Price) { ViewBag.Message = "Bu yarışmaya katılmak için yeterli Bill yok, hesabım kısmından yükleme yapabilirsiniz"; return(Redirect("/Home/Index")); } else { UserTrans trans = new UserTrans(); trans.UserId = appuser.Id; trans.ContestId = bc.Id; trans.Prize = 0; trans.Loose = bc.Price; trans.Balance = totalb - bc.Price; repoUserTrans.Add(trans); } //şuanda yarışmadaki bütün sorular burda -->cd for (int i = 0; i < basic.Capacity; i++) { return(View(basic[i])); } } //başlama tarihi şuan olan yarışma var conlist = repoCon.GetAll(x => x.IsDeleted == false && x.Date > DateTime.Now); //bütün yarışmaları tarihe göre sıralayıp en yakını aldım var cont = conlist.OrderBy(x => x.Date).Take(1).FirstOrDefault(); //başlayacak olan yarışmanın soruları List <ContestDetails> cd = repoConDeta.GetAll(k => k.ContestId == cont.Id).ToList(); if (totalb < cont.Price) { ViewBag.Bakiye = "Bu yarışmaya katılmak için yeterli Bill yok, hesabım kısmından yükleme yapabilirsiniz"; return(Redirect("/Home/Index")); } else { UserTrans trans = new UserTrans(); trans.UserId = appuser.Id; trans.ContestId = cont.Id; trans.Prize = 0; trans.Loose = cont.Price; trans.Balance = totalb - cont.Price; repoUserTrans.Add(trans); } var bonuslist = repoBonus.GetAll(x => x.UserId == appuser.Id && x.IsDeleted == false); if (bonuslist != null) { foreach (var item in bonuslist) { if (item.WheelValueId == 17 || item.WheelValueId == 10) { ViewBag.Saniye = "+"; } } } //şuanda yarışmadaki bütün sorular burda -->cd for (int i = 0; i < cd.Capacity; i++) { return(View(cd[i])); } return(View(cd)); }
public JsonResult UserTrans(string desc) { var usermanager = IdentityTools.NewUserManager(); ApplicationUser kullanici = usermanager.FindByName(User.Identity.Name); Payments pay = new Payments(); if (desc == "10.000 Bill") { UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; userTrans.IsWheel = true; userTrans.Prize = 10000; userTrans.Loose = 1000; userTrans.Balance = totalb + 9000; ent2.Add(userTrans); } else if (desc == "100.000 Bill") { UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; userTrans.IsWheel = true; userTrans.Prize = 100000; userTrans.Loose = 1000; userTrans.Balance = totalb + 99000; ent2.Add(userTrans); } else if (desc == "5.000 Bill") { UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; userTrans.IsWheel = true; userTrans.Prize = 5000; userTrans.Loose = 1000; userTrans.Balance = totalb + 4000; ent2.Add(userTrans); } else if (desc == "Yanlış Cevap Jokeri") { Bonus name = new Bonus(); UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; name.UserId = userTrans.UserId; userTrans.Balance = totalb - 1000; userTrans.Loose = 1000; userTrans.Prize = 0; name.WheelValueId = ent.Get(x => x.Description == "Yanlış Cevap Jokeri").Id; name.BonusName = "Yanlış Cevap Jokeri"; ent3.Add(name); ent2.Add(userTrans); } else if (desc == "+ Saniye") { Bonus name = new Bonus(); UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; name.UserId = userTrans.UserId; userTrans.Loose = 1000; userTrans.Prize = 0; userTrans.Balance = totalb - 1000; name.WheelValueId = ent.Get(x => x.Description == "+ Saniye").Id; name.BonusName = "+ Saniye"; ent3.Add(name); ent2.Add(userTrans); } else if (desc == "Tekrar Çevir") { UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; userTrans.Loose = 0; userTrans.Prize = 0; userTrans.Balance = totalb; ent2.Add(userTrans); // tekrar cevir. } else if (desc == "Boş") { UserTrans userTrans = new UserTrans(); decimal totalb = ent2.TotalBalance(kullanici.Id); userTrans.UserId = kullanici.Id; userTrans.Loose = 1000; userTrans.Prize = 0; userTrans.Balance = totalb - 1000; ent2.Add(userTrans); // Hiç bir şey olmasın } return(Json(desc, JsonRequestBehavior.AllowGet)); }