예제 #1
0
 // GET api/events
 public IEnumerable <Events> GetAllEvent()
 {
     //var user_Login =  _userService.GetUserByUsername(userLogin.Username);
     //if (user_Login.P != userLogin.Password)
     //    return Unauthorized();
     if (_eventServices.GetAll() == null)
     {
         return(null);
     }
     return(_eventServices.GetAll());
 }
예제 #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);
        }
예제 #3
0
        /// <summary>
        ///     Page that display a list of Event that depend on specific criteria
        /// </summary>
        public async Task <IActionResult> Index([FromQuery(Name = "type")] string type, string search, string typeSearch)
        {
            var events = await _context.Events.ToListAsync();

            var eventypes = await _context.EventTypes.ToListAsync();

            if (!String.IsNullOrEmpty(search))
            {
                events = events.Where(c => c.Title.Contains(search)).ToList();//
                // .Where( s => s.EventType.Title.Equals(typeSearch)).ToList();
                //  eventypes = eventypes.Where( x => x.Title.Contains(typeSearch)).ToList();
            }
            else if ((!String.IsNullOrEmpty(typeSearch)))
            {
                // events = events.Where(x => x.EventType.Title.Equals(typeSearch)).ToList();

                events = events.ToList().Where(x => x.EventType.Title == typeSearch).ToList();

                // eventypes = eventypes.Where( x => x.Title.Contains(typeSearch)).ToList();
            }

            else
            {
                events = await(string.IsNullOrEmpty(type) ? _eventServices.GetAll() : _eventTypeServices.GetEventsFromEventTypeName(type));
            }

            IActionResult result = null;

            var addresses = await _context.Addresses.ToListAsync();

            var businesses = await _context.Businesses.ToListAsync();

            var users = await _context.EventApplicationUsers.ToListAsync();

            var comments = await _context.Commentaires.ToListAsync();

            if (events == null)
            {
                result = NotFound();
            }
            else
            {
                var model = new ListEventsViewModel
                {
                    Events     = events,
                    Addresses  = addresses,
                    Businesses = businesses,
                    EventTypes = eventypes
                };

                foreach (var item in model.Events)
                {
                    var links = await _context.EventApplicationUsers
                                .Where(x => x.EventId == item.Id)
                                .ToListAsync();

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

                        item.Members.Add(user);
                    }
                }
                result = View(model);
            }

            return(result);
        }