public bool AddAwardUser(int userId, int awardId)
        {
            var users  = usersDAO.GetAll();
            var awards = awardsDAO.GetAll();

            var user  = users.FirstOrDefault(usr => usr.Id == userId);
            var award = awards.FirstOrDefault(awrd => awrd.Id == awardId);

            if ((user == null) & (award == null))
            {
                return(false);
            }
            else
            {
                AwardUser awardUser = new AwardUser {
                    UserId = userId, AwardId = awardId,
                };

                if (awardsUsersDAO.GetAll().Contains(awardUser))
                {
                    throw new Exception("The user has already paired with the award");
                }
                else
                {
                    var result = awardsUsersDAO.Add(awardUser);

                    return(result);
                }
            }
        }
        public IEnumerable <Award> GetAll()
        {
            var cacheResult = cacheLogic.Get <IEnumerable <Award> >(allAwardsCacheKey);

            if (cacheResult == null)
            {
                var result = awardsDAO.GetAll().ToArray();
                cacheLogic.Add(allAwardsCacheKey, result);

                return(result);
            }
            else
            {
                return(cacheResult);
            }
        }
Exemple #3
0
 public IEnumerable <Award> GetAll()
 {
     return(_awardsDAO.GetAll());
 }