Exemplo n.º 1
0
        public async Task <IActionResult> GetEvent(int id)
        {
            IActionResult result = null;

            var addresses = await _eventServices
                            .GetAll();

            await _eventTypeServices.GetAll();

            var oneEvent = await _eventServices
                           .Get(id);

            if (oneEvent == null)
            {
                result = NotFound();
            }
            else
            {
                var model = new EventViewModel {
                    Event = oneEvent
                };
                model.Event.Address = await _addressServices.Get(oneEvent.Address.Id);

                model.Event.EventType = await _eventTypeServices.Get(oneEvent.EventType.Id);

                model.Event.Commentaires = await _context.Commentaires
                                           .Where(x => x.EventId == oneEvent.Id)
                                           .ToListAsync();

                var links = await _context.EventApplicationUsers
                            .Where(x => x.EventId == oneEvent.Id)
                            .ToListAsync();

                foreach (var link in links)
                {
                    var user = await _userManager
                               .FindByIdAsync(link.ApplicationUserId);

                    model.Event.Members.Add(user);
                }

                result = View("Event", model);
            }

            return(result);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> GetBusiness(int id)
        {
            IActionResult result = null;

            var addresses = await _eventServices
                            .GetAll();

            await _businessServices.GetAll();


            var oneBusiness = await _businessServices
                              .Get(id);

            if (oneBusiness == null)
            {
                result = NotFound();
            }
            else
            {
                var model = await _businessServices.Get(oneBusiness.Id);

                model.Address = await _addressServices.Get(oneBusiness.Address.Id);

                model.Events = await _context.Events.Where(x => x.Id == oneBusiness.Id).ToListAsync();

                // model.Events = await _eventServices.GetAll();
                await _eventTypeServices.GetAll();


                // var links = await _context.EventApplicationUsers
                //     .Where(x => x.EventId == oneEvent.Id)
                //     .ToListAsync();



                result = View("Business", model);
            }

            return(result);
        }