private ActionResult FillWinner(BingoViewModel model) { //save the winner TBingo bingo = bingoTasks.GetByDate(model.BingoDate); if (bingo != null) { bingo.BingoWinner = model.TheWinner; bingo.ModifiedDate = DateTime.Now; bingo.ModifiedBy = User.Identity.Name; bingo.DataStatus = "Updated"; bingoTasks.Update(bingo); } return(RedirectToAction("Bingo", "Contest", new { bingoDate = model.BingoDate })); }
public ActionResult Bingo(DateTime?bingoDate) { if (!bingoDate.HasValue) { bingoDate = DateTime.Today; } TBingo bingo = bingoTasks.GetByDate(bingoDate.Value); BingoViewModel vm = new BingoViewModel(); vm.BingoDate = bingoDate.Value; vm.DayOfWeek = (int)vm.BingoDate.DayOfWeek; vm.ImageFile = BingoViewModel.EmptyImage; if (bingo != null) { vm.BingoId = bingo.Id; vm.BingoStatus = bingo.BingoStatus; if (bingo.BingoStatus == "YES") { vm.ImageFile = BingoViewModel.BingoImage; } else { vm.ImageFile = BingoViewModel.NoBingoImage; } //vm.Winner1 = "AUN"; //vm.Winner2 = "DARWIN"; //vm.Winner3 = "RINA"; //vm.Winner4 = "EDI YANTO"; //vm.Winner5 = "JOHN"; vm.TheWinner = bingo.BingoWinner; } else { vm.BingoId = Guid.NewGuid().ToString(); } return(View(vm)); }
public TBingo GetBingoByWeekStatus(int week, int year, string bingoStatus) { TBingo bingo = this._tBingoRepository.GetBingoByWeekStatus(week, year, bingoStatus); return(bingo); }
private ActionResult FillBingo(BingoViewModel model) { if (model.BingoDate == DateTime.Today) { if (DateTime.Now.AddHours(7).Hour < 17) { return(RedirectToAction("Bingo", "Contest", new { bingoDate = model.BingoDate })); } } else if (model.BingoDate > DateTime.Today) { return(RedirectToAction("Bingo", "Contest", new { bingoDate = model.BingoDate })); } TBingo bingo = bingoTasks.GetByDate(model.BingoDate); if (bingo != null) { bingo.ModifiedDate = DateTime.Now; bingo.ModifiedBy = User.Identity.Name; bingo.DataStatus = "Updated"; bingoTasks.Update(bingo); } else { //var bingo = bingoTasks.GetBingoByWeek(model.BingoDate.week); // Gets the Calendar instance associated with a CultureInfo. CultureInfo myCI = CultureInfo.CurrentCulture; System.Globalization.Calendar myCal = myCI.Calendar; // Gets the DTFI properties required by GetWeekOfYear. CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule; DayOfWeek myFirstDOW = myCI.DateTimeFormat.FirstDayOfWeek; int week = myCal.GetWeekOfYear(model.BingoDate, myCWR, myFirstDOW); TBingo bingoWinThisWeek = bingoTasks.GetBingoByWeekStatus(week, model.BingoDate.Year, "YES"); int dayOfWeek = (int)model.BingoDate.DayOfWeek; string stat = ""; //no winner yet if (bingoWinThisWeek == null) { RandomizeWin(dayOfWeek, ref stat); } //we have a winner, set no winner anymore else { //jika blm ada pemenang, maka cari yg menang if (string.IsNullOrEmpty(bingoWinThisWeek.BingoWinner)) { RandomizeWin(dayOfWeek, ref stat); } else { stat = "NO"; } } bingo = new TBingo(); bingo.SetAssignedIdTo(Guid.NewGuid().ToString()); bingo.BingoDate = model.BingoDate; bingo.BingoStatus = stat; bingo.BingoWeek = week; bingo.BingoMonth = model.BingoDate.Month; bingo.BingoYear = model.BingoDate.Year; bingo.BingoWinner = string.Empty; bingo.CreatedDate = DateTime.Now; bingo.CreatedBy = User.Identity.Name; bingo.DataStatus = "New"; bingoTasks.Insert(bingo); } // If we got this far, something failed, redisplay form return(RedirectToAction("Bingo", "Contest", new { bingoDate = model.BingoDate })); }
public TBingo GetByDate(DateTime bingoDate) { TBingo bingo = this._tBingoRepository.GetByDate(bingoDate); return(bingo); }