public List <WinnerDetailsModel> WinnerUserDetails(WinnerUsersModel model) { var data = entities.Challanges.Where(x => x.ChallangeId == model.ChallangeId && x.IsAccepted == true).ToList(); List <WinnerDetailsModel> winnerDetails = new List <WinnerDetailsModel>(); foreach (var item in data) { var Win = new WinnerDetailsModel(); if ((bool)item.IsWinner) { Win.Name = item.Name; Win.Phone = item.Phone; Win.Points = (int)item.Points; Win.IsWinner = item.IsWinner; } else { Win.Name = item.Name; Win.Phone = item.Phone; Win.Points = 0; Win.IsWinner = item.IsWinner; } winnerDetails.Add(Win); } return(winnerDetails); }
public List <WinnerUsersModel> WinnerUsersList() { var data = entities.Challanges.Where(x => x.IsWinner == true).OrderByDescending(x => x.CompletedDateTime).ToList(); List <WinnerUsersModel> winnerUsers = new List <WinnerUsersModel>(); foreach (var item in data) { var Win = new WinnerUsersModel(); Win.UserId = item.UserId; Win.Name = item.Name; Win.ChallangeId = (int)item.ChallangeId; Win.WinDate = string.Format("{0:dd MMMM, yyyy}", item.CompletedDateTime); winnerUsers.Add(Win); } return(winnerUsers); }