Ejemplo n.º 1
0
        //
        // GET: /Admin/Keg/
        public ActionResult Index()
        {
            var kegs  = _kegOrchestrator.GetKegs();
            var model = new KegViewModel()
            {
                Kegs = new List <KegModel>()
            };

            kegs.ForEach((k) =>
            {
                var keg      = AutoMapper.Mapper.Map <Keg, KegModel>(k);
                keg.BeerName = _beerOrchestrator.GetById(k.BeerId).Name;
                model.Kegs.Add(keg);
            });

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(string id)
        {
            var kegs      = _kegOrchestrator.GetKegs(false).ToList();
            var tap       = _tapOrchestrator.GetTapById(id);
            var kegModels = kegs.Select(k => AutoMapper.Mapper.Map <Keg, KegModel>(k)).ToList();

            foreach (var keg in kegs)
            {
                var beer = _beerOrchestrator.GetById(keg.BeerId);
                var km   = kegModels.FirstOrDefault(k => k.Id == keg.Id);
                if (null != km)
                {
                    km.BeerName = beer.Name;
                }
            }
            var vm = new EditTapViewModel(kegModels, tap.KegId);

            return(View(vm));
        }
Ejemplo n.º 3
0
        //
        // GET: /Admin/Beer/Details/My-Beer-Name
        public ActionResult Details(string id)
        {
            var beer = _beerOrchestrator.GetById(id);

            return(View(AutoMapper.Mapper.Map <Beer, BeerViewModel>(beer)));
        }