public JsonResult SlottoLogin() { int b = 1; SlotVewModel slotvm = new SlotVewModel(); if (User.Identity.GetUserId() == null) { b = 4; } else { List <AssetsViewModel> avList = new List <AssetsViewModel>(); avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()); slotvm.usermoney = avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset; var u = new H5GameRepository().Usercount(User.Identity.GetUserId()).Where(x => x.gameModel == 5).FirstOrDefault(); if (u == null) { DailyGameCount d = new DailyGameCount { userId = User.Identity.GetUserId(), gameModel = 5, count = 0 }; u = new H5GameRepository().DaycountCreate(d); } int r = new Random().Next(1, 14); slotvm.slotm = new H5GameRepository().GetSlotCash(r); } slotvm.loginUser = b; return(Json(slotvm, JsonRequestBehavior.AllowGet)); }
//每日更新 public void DailyUpdate(DailyGameCount instance) { if (instance == null) { throw new ArgumentNullException("instance"); } else { Db.Entry(instance).State = EntityState.Modified; this.SaveChanges(); } }
//無每日新增新進資料 public DailyGameCount DaycountCreate(DailyGameCount instance) { if (instance == null) { throw new ArgumentNullException("instance"); } else { Db.DailyGameCount.Add(instance); this.SaveChanges(); return(instance); } }
public int BricktoCount() { //1:沒問題 4:沒登入 5:沒錢 0:沒每日 int b = 1; if (User.Identity.GetUserId() != null) { var u = new H5GameRepository().Usercount(User.Identity.GetUserId()).Where(x => x.gameModel == 4).FirstOrDefault(); if (u == null && User.Identity.GetUserId() != null) { DailyGameCount d = new DailyGameCount { userId = User.Identity.GetUserId(), gameModel = 4, count = 5 }; u = new H5GameRepository().DaycountCreate(d); } List <AssetsViewModel> avList = new List <AssetsViewModel>(); avList = new AssetsRepository().getAssetsListByUserID(User.Identity.GetUserId()); if (avList.Where(x => x.unitSn == 1).FirstOrDefault().Asset < 200) { b = 5; } if (u.count == 0) { b = 0; } } else { b = 4; } return(b); }