Пример #1
0
        public IActionResult Create(string HostId, HostEventsViewModel hostEventsViewModel)
        {
            if (ModelState.IsValid)
            {
                PasswordHasher passwordHasher = new PasswordHasher();
                //var password = passwordHasher.HashToString(hostEventsViewModel.HostEvent.EventPassword);

                HostEvent hostEvent = new HostEvent()
                {
                    EventTitle       = hostEventsViewModel.HostEvent.EventTitle,
                    EventDescription = hostEventsViewModel.HostEvent.EventDescription,
                    EventDate        = hostEventsViewModel.HostEvent.EventDate,
                    //EventPassword = password,
                    EventPassword = passwordHasher.HashToString(hostEventsViewModel.HostEvent.EventPassword),
                    Location      = hostEventsViewModel.HostEvent.Location,
                    HostId        = _userManager.GetUserId(User),
                    MaxReservable = hostEventsViewModel.HostEvent.MaxReservable,
                    Status        = hostEventsViewModel.HostEvent.Status,
                };

                if (hostEventsViewModel.HostEvent.Status == null)
                {
                    hostEvent.Status = "TBC";
                }
                ;


                _hostEventsRepository.CreateHostEvent(hostEvent);
                return(RedirectToAction("Index"));
            }
            return(View("Create"));
        }
Пример #2
0
        public IActionResult Edit(int EventId)
        {
            HostEvent hostEvent = _hostEventsRepository.GetHostEvent(EventId);

            List <SelectListItem> Status = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = "TBA", Value = "TBA"
                },
                new SelectListItem()
                {
                    Text = "Upcoming", Value = "Upcoming"
                },
                new SelectListItem()
                {
                    Text = "Postponed", Value = "Postponed"
                },
                new SelectListItem()
                {
                    Text = "Cancelled", Value = "Cancelled"
                }
            };

            HostEventsViewModel hostEventsViewModel = new HostEventsViewModel()
            {
                HostEvent = hostEvent,
                EventId   = hostEvent.EventId,
                Status    = Status
            };

            return(View(hostEventsViewModel));
        }
Пример #3
0
 public void CreateHostEvent(HostEvent hostEvent)
 {
     if (hostEvent.Status != "Upcoming")
     {
         hostEvent.EventDate = null;
     }
     _appDbContext.HostEvents.Add(hostEvent);
     _appDbContext.SaveChanges();
 }
Пример #4
0
        public void DeleteHostEvent(int EventId)
        {
            HostEvent    hostEvent = GetHostEvent(EventId);
            List <Guest> guests    = _appDbContext.Guests.Where(x => x.EventId == EventId).ToList();

            foreach (var guest in guests)
            {
                _appDbContext.Guests.Remove(guest);
            }
            _appDbContext.HostEvents.Remove(hostEvent);
            _appDbContext.SaveChanges();
        }
Пример #5
0
        public bool CheckGiftLimit(string UserId, int EventId)
        {
            HostEvent hostEvent = _appDbContext.HostEvents.Single(x => x.EventId == EventId);
            //int numReserved = _appDbContext.Gifts.Count(x => x.EventId == EventId && x.GuestId == UserId && x.Status == "Reserved");
            //int numBought = _appDbContext.Gifts.Count(x => x.EventId == EventId && x.GuestId == UserId && x.Status == "Bought");
            int numOwned = _appDbContext.Gifts.Count(x => x.EventId == EventId && x.GuestId == UserId);

            if (hostEvent.MaxReservable > numOwned)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Logic for responding to chat events
        /// </summary>
        /// <param name="chatEvent"></param>
        private void RespondToEvent(Event chatEvent)
        {
            // Logic for responding to a "PING" event
            if (chatEvent.GetType().Equals(typeof(PingEvent)))
            {
                ircClient.SendIrcString("PONG");
                Log.Message(chatEvent.ToString(), false);
            }

            // Logic for responding to a "PRIVMSG" event
            else if (chatEvent.GetType().Equals(typeof(ChatEvent)))
            {
                // Check all the chat roomms currently connected, then respond to the correct channel
                ChatEvent chatMessage = (ChatEvent)chatEvent;
                foreach (TwitchChatRoom chatroom in chatrooms)
                {
                    if (chatMessage.Channel.Equals(chatroom.Channel.ChannelName))
                    {
                        chatroom.RespondToEvent(chatEvent);
                        break;
                    }
                }
            }

            // Logic for responding to a "WHISPER" event
            else if (chatEvent.GetType().Equals(typeof(WhisperEvent)))
            {
                Log.Message(chatEvent.ToString(), true);
            }

            // Logic for responding to a "HOST" event
            else if (chatEvent.GetType().Equals(typeof(HostEvent)))
            {
                HostEvent hostData = (HostEvent)chatEvent;
                ircClient.SendChatMessage(hostData.Hostee, chatEvent.ToString());
                Log.Message(hostData.ToString(), true);
            }

            // Logic for responding to an unknown event
            else
            {
                //Log.Message(chatEvent.ToString(), false);
            }
        }
Пример #7
0
        public void UpdateHostEvent(HostEvent hostEvent)
        {
            HostEvent updatedHostEvent = GetHostEvent(hostEvent.EventId);

            updatedHostEvent.EventTitle       = hostEvent.EventTitle;
            updatedHostEvent.Location         = hostEvent.Location;
            updatedHostEvent.EventDescription = hostEvent.EventDescription;
            if (hostEvent.Status == "Upcoming")
            {
                updatedHostEvent.EventDate = hostEvent.EventDate;
            }
            else
            {
                updatedHostEvent.EventDate = null;
            }
            updatedHostEvent.EventPassword = hostEvent.EventPassword;
            updatedHostEvent.MaxReservable = hostEvent.MaxReservable;
            updatedHostEvent.Status        = hostEvent.Status;

            _appDbContext.Update(updatedHostEvent);
            _appDbContext.SaveChanges();
        }
Пример #8
0
        public string GetHost(int EventId)
        {
            HostEvent hostevent = _appDbContext.HostEvents.Single(x => x.EventId == EventId);

            return(hostevent.HostId);
        }