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 <User> GetAll() { try { return(_usersDAO.GetAll()); } catch (Exception ex) { Logger.Log.Error(ex.Message); return(null); } }
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); }
public IEnumerable <User> GetAll() { return(_usersDAO.GetAll()); }