Exemplo n.º 1
0
        public async Task <IActionResult> Create(CreateBusinessView model)
        {
            _context.Add(model.address);
            await _context.SaveChangesAsync();

            Address newAddress = await _addressServices.Get(model.address.Id);

            model.business.Address = newAddress;

            _context.Add(model.business);

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 2
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.º 3
0
 [HttpGet("{id}")] //Address/5
 public Address Get(int id)
 {
     return(_addressServices.Get(id));
 }