private void cmbLocations_SelectedIndexChanged(object sender, EventArgs e)
        {
            _location = (Location) cmbLocations.SelectedItem;

            _locationGuestCount = LogicCollection.GuestLogic.GetGuestCountByLocation(_location);
            lblLocationCapacity.Text = $"{_locationGuestCount} / {_location.Capacity}";
        }
        public bool Delete(Location entity)
        {
            var location = _locations.FirstOrDefault(e => e.ID == entity.ID);
            if (location == null) return false;

            _locations.Remove(location);
            return true;
        }
        public Location Insert(Location entity)
        {
            if (GetById(entity.ID) != null) return null;

            var id = _locations.Max(e => e.ID);
            var location = new Location(id, entity.EventID, entity.Name, entity.Capacity, entity.Price, entity.Coordinates);
            _locations.Add(location);

            return location;
        }
Exemple #4
0
        public Guest RegisterNewUserForEvent(string username, Event ev, Location location, DateTime start, DateTime end, int leaderID)
        {
            var password = Membership.GeneratePassword(10, 2);

            var user = new User(0, username, LogicCollection.UserLogic.GetHashedPassword(password), "new user");
            user = LogicCollection.UserLogic.RegisterUser(user, true, password);

            SendConfirmationEmail(user, ev, location, start, end);

            return RegisterUserForEvent(user, ev, location, start, end, leaderID);
        }
Exemple #5
0
        public Guest RegisterUserForEvent(User user, Event ev, Location location, DateTime start, DateTime end, int leaderID = 0)
        {
            var existingGuest = _context.GetGuestByEvent(ev, user.ID); // Checks if user is already registered for an event
            if (existingGuest != null) return existingGuest;

            var guest = new Guest(user.ID, user.Username, user.Password, user.Name, "", false, ev.ID, false, start, end,
                location.ID, user.RegistrationDate, user.Permission, user.Surname, user.Country, user.City, user.Postal,
                user.Address, user.Telephone, leaderID);

            SendConfirmationEmail(user, ev, location, start, end);

            FtpHelper.CreateDirectory($"{ev.ID}/{guest.ID}");

            return _context.Insert(guest);
        }
Exemple #6
0
        public List<Guest> RegisterUsersForEvent(List<string> usernames, Event ev, Location location, DateTime start, DateTime end, int leaderID)
        {
            var res = new List<Guest>();

            foreach (var username in usernames)
            {
                var user = LogicCollection.UserLogic.GetByUsername(username);
                var guest = (user != null
                    ? RegisterUserForEvent(user, ev, location, start, end)
                    : RegisterNewUserForEvent(username, ev, location, start, end, leaderID));

                res.Add(guest);
            }

            return res;
        }
Exemple #7
0
 public int GetGuestCountByLocation(Location location)
 {
     return _context.GetGuestCountByLocation(location);
 }
Exemple #8
0
        /// <summary>
        /// Sends a confirmation email to given user
        /// </summary>
        /// <param name="user">user to send confirmation email to</param>
        /// <returns>true if mail was successfully send, throws exception if sending mail fails</returns>
        private static bool SendConfirmationEmail(User user, Event ev, Location location, DateTime start, DateTime end)
        {
            // TODO: Add this to settings boyo
            var fromAddress = new MailAddress("*****@*****.**", "ICT4Events");
            var toAddress = new MailAddress(user.Username, user.Name);
            const string fromPassword = "******";

            var message = new MailMessage("*****@*****.**", "*****@*****.**")
            {
                Subject = "Confirmation of your new user account for ICT4Events",
                Body =
                    "Hello " + user.Name + ",\r\n\r\n" +
                    $"Your have been registered to participate in event {ev.Name}!\r\n" +
                    $"The location you entered is {location.Name}.\r\n" +
                    $"We will be expecting to see you on {start.Date} until {end.Date}." +
                    "\r\n\r\nHave a nice day!"
            };

            var smtp = new SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            try
            {
                smtp.Send(message);
                return true;
            }
            catch (SmtpException e)
            {
                throw new Exception(e.Message);
            }
        }
 public bool UpdateLocation(Location location)
 {
     return _context.Update(location);
 }
 public Location InsertLocation(Location location)
 {
     return _context.Insert(location);
 }
 public bool DeleteLocation(Location location)
 {
     return _context.Delete(location);
 }
 public int GetGuestCountByLocation(Location location)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Sends a confirmation email to given user
        /// </summary>
        /// <param name="user">user to send confirmation email to</param>
        /// <returns>true if mail was successfully send, throws exception if sending mail fails</returns>
        private static bool SendConfirmationEmail(User user, Event ev, Location location, DateTime start, DateTime end)
        {
            var fromAddress = new MailAddress(Properties.Settings.Default.Email, "ICT4Events");
            var toAddress = new MailAddress(user.Username, user.Name);
            var fromPassword = Properties.Settings.Default.EmailPassword;

            var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = "Confirmation of your new user account for ICT4Events",
                Body =
                    "Hello " + user.Name + ",\r\n\r\n" +
                    $"Your have been registered to participate in event {ev.Name}!\r\n" +
                    $"The location you entered is {location.Name}.\r\n" +
                    $"We will be expecting to see you on {start.Date} until {end.Date}.\r\n" +
                    $"Your user ID is: {user.ID}. Make sure to remember this for your check-in!" +
                    "\r\n\r\nHave a nice day!"
            };

            var smtp = new SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
            };

            try
            {
                smtp.Send(message);
                return true;
            }
            catch (SmtpException e)
            {
                throw new Exception(e.Message);
            }
        }