public GetYourRewardsRespond GetYourRewards(GetYourRewardsRequest request) { var invalidDataModel = new GetYourRewardsRespond { ContactNo = string.Empty, AllRewards = Enumerable.Empty<YourRewardInformation>(), CurrentRewards = Enumerable.Empty<YourRewardInformation>() }; var isArgumentValid = request != null && !string.IsNullOrEmpty(request.UserId); if (!isArgumentValid) return invalidDataModel; var rewardDac = FacadeRepository.Instance.RewardDataAccess; var allWinRewards = rewardDac.GetWinnersByUserId(request.UserId); var allRewards = rewardDac.GetRewardsByIds(allWinRewards.Select(it => it.RewardId)); var allRewardGroups = rewardDac.GetRewardGroup().ToList(); var currentRewardGroup = allRewardGroups.OrderByDescending(it => it.ExpiredDate).FirstOrDefault(); if (currentRewardGroup == null) return invalidDataModel; var currentRewardQry = allRewards.Where(it => it.RewardGroupId == currentRewardGroup.Id); var otherRewardQry = allRewards.Except(currentRewardQry); int ordering = 1; var currentRewards = convertToYourReward(currentRewardQry, allWinRewards, allRewardGroups, ref ordering).Where(it => it != null); var otherRewards = convertToYourReward(otherRewardQry, allWinRewards, allRewardGroups, ref ordering).Where(it => it != null); return new GetYourRewardsRespond { ContactNo = "123-456-789", // HACK: Contact No CurrentRewards = currentRewards, AllRewards = otherRewards }; }
public GetYourRewardsRespond GetYourRewards(string userId) { var request = new GetYourRewardsRequest { UserId = userId }; var result = FacadeRepository.Instance.RewardFacade.GetYourRewards(request); return result; }