コード例 #1
0
        public Keg GetById(string id)
        {
            var KegItem = Kegs.Find(b => b.id == id).FirstOrDefault();

            KegItem = AttachEntities(KegItem);
            return(KegItem);
        }
コード例 #2
0
        public IEnumerable <Keg> GetAll()
        {
            var KegList = Kegs.Find(b => true).ToList();

            KegList = AttachEntities(KegList).ToList();
            return(KegList);
        }
コード例 #3
0
        internal IEnumerable <PourEvent> AttachEntities(IEnumerable <PourEvent> pourEventList)
        {
            //Load Kegs
            var kegIdsToLoad = pourEventList.Select(p => p.kegId).Distinct().ToList();
            var kegs         = Kegs.Find(k => kegIdsToLoad.Contains(k.id)).ToList();

            kegs = AttachEntities(kegs).ToList();
            //Load Taps
            var tapIdsToLoad = pourEventList.Select(p => p.tapId).Distinct().ToList();
            var taps         = Taps.Find(t => tapIdsToLoad.Contains(t.id)).ToList();

            taps = AttachEntities(taps).ToList();

            pourEventList.ToList().ForEach(p => {
                if (p.kegId != null)
                {
                    p.keg = kegs.FirstOrDefault(k => k.id == p.kegId);
                }
                if (p.tapId != null)
                {
                    p.tap = taps.FirstOrDefault(t => t.id == p.tapId);
                }
            });
            return(pourEventList);
        }
コード例 #4
0
 internal Tap AttachEntities(Tap tapItem)
 {
     if (tapItem != null && tapItem.current_keg_id != null)
     {
         var keg = Kegs.Find(k => k.id == tapItem.current_keg_id).FirstOrDefault();
         keg = AttachEntities(keg);
         tapItem.current_keg = keg;
     }
     return(tapItem);
 }
コード例 #5
0
 internal PourEvent AttachEntities(PourEvent pourEventItem)
 {
     if (pourEventItem != null && pourEventItem.kegId != null)
     {
         var keg = Kegs.Find(k => k.id == pourEventItem.kegId).FirstOrDefault();
         keg = AttachEntities(keg);
         pourEventItem.keg = keg;
     }
     if (pourEventItem != null && pourEventItem.tapId != null)
     {
         var tap = Taps.Find(t => t.id == pourEventItem.tapId).FirstOrDefault();
         tap = AttachEntities(tap);
         pourEventItem.tap = tap;
     }
     return(pourEventItem);
 }
コード例 #6
0
        internal IEnumerable <Tap> AttachEntities(IEnumerable <Tap> tapList)
        {
            //Load Kegs
            var kegIdsToLoad = tapList.Select(t => t.current_keg_id).Distinct().ToList();
            var kegs         = Kegs.Find(k => kegIdsToLoad.Contains(k.id)).ToList();

            kegs = AttachEntities(kegs).ToList();

            tapList.ToList().ForEach(t => {
                if (t.current_keg_id != null)
                {
                    var current_keg = kegs.FirstOrDefault(k => k.id == t.current_keg_id);
                    t.current_keg   = current_keg;
                }
            });
            return(tapList);
        }