public void TryUpdateInstantLotteryWinnerSuccess() { var entry = new KittyJusticeLeagueInstantLottery { Id = 1, CreateDate = new DateTime(2017, 11, 13), IpAddress = "127.0.0.1", Channel = Domain.Abstract.ChannelType.Mobile, PrizeType = KittyJusticeLeagueInstantLotteryPrizeType.JoyGifticon, Name = "홍길동", Mobile = "01012345678", UpdateDate = new DateTime(2017, 11, 13) }; repo.Setup(x => x.Any(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLottery, bool> > >())).Returns(false); repo.Setup(x => x.Update(It.IsAny <KittyJusticeLeagueInstantLottery>())).Returns(entry); //action var result = service.UpdateInstantLotteryWinner(entry); //assert Assert.NotNull(result); Assert.Equal(result.PrizeType, KittyJusticeLeagueInstantLotteryPrizeType.JoyGifticon); repo.Verify(x => x.Any(It.IsAny <Expression <Func <KittyJusticeLeagueInstantLottery, bool> > >()), Times.Once); repo.Verify(x => x.Update(It.IsAny <KittyJusticeLeagueInstantLottery>()), Times.Once); repo.Verify(x => x.Save(), Times.Once); }
public ActionResult KittyJusticeLeagueUpdateWinner(KittyJusticeLeagueModel model) { try { if (common.Now >= new DateTime(2017, 12, 18)) { throw new KittyJusticeLeagueServiceException("400", "이벤트가 종료되었습니다.", null); } // 당첨자 세션 check long?entryId = Session["KittyJusticeLeagueEntryId"] as long?; KittyJusticeLeagueInstantLotteryPrizeType?prize = Session["KittyJusticeLeaguePrizeType"] as KittyJusticeLeagueInstantLotteryPrizeType?; if (!entryId.HasValue || entryId.Value != model.Id) { throw new KittyJusticeLeagueServiceException("400", "당첨자가 아닙니다.", model.Id); } if (!prize.HasValue || prize.Value != model.PrizeType) { throw new KittyJusticeLeagueServiceException("400", "해당 경품 당첨자가 아닙니다.", model.PrizeType); } var user = service.GetInstantLotteryWinner(model.Id); var entity = mapperConfig.CreateMapper().Map <KittyJusticeLeagueModel, KittyJusticeLeagueInstantLottery>(model, user); entity.UpdateDate = common.Now; service.UpdateInstantLotteryWinner(entity); return(Json(new { result = true })); } catch (Exception e) { return(Json(new { result = false, message = e.Message })); } }
public void KittyJusticeLeagueUpdateWinner(KittyJusticeLeagueModel model) { // 당첨자 세션 check long?entryId = HttpContext.Current.Session["KittyJusticeLeagueEntryId"] as long?; KittyJusticeLeagueInstantLotteryPrizeType?prize = HttpContext.Current.Session["KittyJusticeLeaguePrizeType"] as KittyJusticeLeagueInstantLotteryPrizeType?; if (!entryId.HasValue || entryId.Value != model.Id) { throw new KittyJusticeLeagueServiceException("400", "당첨자가 아닙니다.", model.Id); } if (!prize.HasValue || prize.Value != model.PrizeType) { throw new KittyJusticeLeagueServiceException("400", "해당 경품 당첨자가 아닙니다.", model.PrizeType); } var user = service.GetInstantLotteryWinner(model.Id); var entity = mapperConfig.CreateMapper().Map <KittyJusticeLeagueModel, KittyJusticeLeagueInstantLottery>(model, user); entity.UpdateDate = common.Now; service.UpdateInstantLotteryWinner(entity); }