Esempio n. 1
0
        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);
                }
            }
        }
Esempio n. 2
0
 public IEnumerable <User> GetAll()
 {
     try
     {
         return(_usersDAO.GetAll());
     }
     catch (Exception ex)
     {
         Logger.Log.Error(ex.Message);
         return(null);
     }
 }
Esempio n. 3
0
        public IEnumerable <User> GetAll()
        {
            var cacheResult = cacheLogic.Get <IEnumerable <User> >(AllUsersCacheKey);

            if (cacheResult == null)
            {
                var users = usersDAO.GetAll().ToArray();

                foreach (User user in users)
                {
                    user.UserAwards = awardUsersLogic.GetAwards(user.Id);
                }

                cacheLogic.Add(AllUsersCacheKey, users);
                return(users);
            }
            return(cacheResult);
        }
Esempio n. 4
0
 public IEnumerable <User> GetAll()
 {
     return(_usersDAO.GetAll());
 }