Exemplo n.º 1
0
        public ICollection<UnitWrapper> GetRecommendedUnits(UserWrapper user, int RecommendationCount)
        {
            int _numberOfDisplayedUnits = RecommendationCount <0 ? _maxNumberOfDisplayedUnits : RecommendationCount;

            UnitAccess access = new UnitAccess();
            ICollection<UnitWrapper> candidates;

            if (user == null)
            {
                candidates = access.GetUnits().ToList();
            }
            else
            {

                candidates = access.GetUnitsByDicipline(user.Dicipline.ToList()).ToList();
                if (candidates.Count() < _numberOfDisplayedUnits)
                {
                    int num = _numberOfDisplayedUnits - candidates.Count();

                    foreach (var unitWrapper in access.GetUnits().OrderByDescending(d=>d.AverageRating).Take(num))
                    {
                        candidates.Add(unitWrapper);
                    }
                }
            }

            return candidates.OrderByDescending(d => d.AverageRating).ToList().GetRange(0, candidates.Count() >= _numberOfDisplayedUnits ? _numberOfDisplayedUnits : candidates.Count());
        }
Exemplo n.º 2
0
        public UnitWrapper GetUnit(string unitCode)
        {
            if (string.IsNullOrEmpty(unitCode))
            {
                return null;
            }

            var unitAccess=new UnitAccess();
            var result = unitAccess.GetUnit(unitCode);

            return result.FirstOrDefault();
        }
Exemplo n.º 3
0
        public Dictionary<String, List<UnitWrapper>> GetUnitsPerDiscipline()
        {
            UnitAccess unitAccess=new UnitAccess();

            var result = unitAccess.GetUnits();

            Dictionary<string,List<UnitWrapper>> dic=new Dictionary<string, List<UnitWrapper>>();

            foreach (UnitWrapper u in unitAccess.GetUnits())
            {
                if(!dic.ContainsKey(u.Dicipline.Name))
                    dic.Add(u.Dicipline.Name,new List<UnitWrapper>());

                dic[u.Dicipline.Name].Add(u);
            }

            //return result.Select(unit => new UnitWrapper {UnitObject = unit}).ToList();
            return dic;
        }
Exemplo n.º 4
0
        public Dictionary<string, List<UnitWrapper>> GetUnitsPerDiscipline(String filterText)
        {
            UnitAccess unitAccess = new UnitAccess();

            var result = unitAccess.GetUnits().Where(w=>w.Name.ToLower().Contains(filterText.ToLower()) || w.UnitCode.ToLower().Contains(filterText.ToLower())||w.Description.ToLower().Contains(filterText.ToLower())||w.Dicipline.Name.ToLower().Contains(filterText.ToLower()));

            Dictionary<string, List<UnitWrapper>> dic = new Dictionary<string, List<UnitWrapper>>();

            foreach (UnitWrapper u in result)
            {
                if (!dic.ContainsKey(u.Dicipline.Name))
                    dic.Add(u.Dicipline.Name, new List<UnitWrapper>());

                dic[u.Dicipline.Name].Add(u);
            }

            return dic;
        }
Exemplo n.º 5
0
        public void UpdateResponse(ResponseWrapper response)
        {
            response.Time = DateTime.Now;

            UnitAccess unitAccess = new UnitAccess();
            unitAccess.UpdateResponse(response);
        }
Exemplo n.º 6
0
        public void InsertResponse(ResponseWrapper response)
        {
            response.Time = DateTime.Now;

            UnitAccess unitAccess=new UnitAccess();
            unitAccess.AddResponse(response);
        }