Beispiel #1
0
 protected void Page_Init(object sender, EventArgs e)
 {
     //Drugs = Lib.Systems.Lists.GetMyDrugs();
     long profileId = Lib.Systems.Security.GetCurrentProfile().ID.Value;
     Drugs = _drugListSvc.GetDrugListByProfileId(profileId, DrugListType.MyDrugs);
     Eocs = _complianceSvc.GetEocs().ToList();
 }
Beispiel #2
0
        public DrugList GetDrugListByProfileId(long profileId, string listType)
        {
            if(listType == DrugListType.Undefined)
                throw new ArgumentException("ListType.Undefined is not currently supported.");

            DrugList retList;

            var eocs = _complianceSvc.GetEocsStatus(profileId, listType);

            if(eocs == null)
                return null;

            // set IsFav = true assuming it's the favorites list
            retList = new DrugList
            {
                Id = _drugListRepo.GetDrugListId(profileId, listType),
                ListName = listType,
                UserProfileId = profileId,
                Drugs =
                    (from eoc in eocs
                        select new DrugListItem
                        {
                            Id = eoc.Key.Id,
                            DrugName = eoc.Key.GenericName,
                            DateAdded = DateTime.Now,
                            DrugEocsCount = eoc.Value.Count(),
                            UserEocsCount = eoc.Value.Count(x => x.CompletedAt.HasValue),
                            IsFav = true
                        }).ToList()
            };

            // if it isn't the favorites list then we actaully need to do some work
            // to determin what the IsFav value realy should be.
            if(listType != DrugListType.Favorites)
            {
                IEnumerable<long> favList = _drugListRepo.GetFavList(profileId);
                retList.Drugs.ForEach(x => x.IsFav = favList.Contains(x.Id));
            }

            return retList;
        }