Esempio n. 1
0
        /// <summary>
        /// Adds a new account to the database.
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="fullname"></param>
        /// <param name="email"></param>
        public void CreateAccount(string username, string password, string fullname, string email)
        {
            // Converts plain text password to MD5 hash
            // then to SHA256 then hashes and salts
            // password with BCrypt encrypted hash
            password = Password.HashRaw(password);

            using (var conn = Connection)
            using (var cmd = new InsertCommand("INSERT INTO `accounts` {0}", conn))
            {
                cmd.Set("username", username);
                cmd.Set("password", password);
                cmd.Set("email", email);
                cmd.Set("fullname", fullname);
                cmd.Set("lastLogin", DateTime.Now);
                cmd.Set("creation", DateTime.Now);

                cmd.Execute();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a participant record for an appointment
        /// </summary>
        /// <param name="appointmentId"></param>
        /// <param name="participant"></param>
        public void CreateParticipant(int appointmentId, string participant)
        {
            using (var conn = Connection)
            using (var cmd = new InsertCommand("INSERT INTO `participants` WHERE {0}", conn))
            {
                cmd.Set("appointmentId", appointmentId);
                cmd.Set("participant", participant);

                cmd.Execute();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Adds a new appointment to the database
        /// </summary>
        /// <param name="appointmentId"></param>
        /// <param name="creator"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="description"></param>
        /// <param name="participants"></param>
        public void CreateAppointment(int appointmentId, string creator, DateTime start, DateTime end, string description, List<string> participants)
        {
            using (var conn = Connection)
            using (var cmd = new InsertCommand("INSERT INTO `appointments` WHERE {0}", conn))
            {
                cmd.Set("appointmentId", appointmentId);
                cmd.Set("creator", creator);
                cmd.Set("description", description);
                cmd.Set("start", start);
                cmd.Set("end", end);

                cmd.Set("creation", DateTime.Now);

                cmd.Execute();
            }
            foreach (var participant in participants)
            {
                CreateParticipant(appointmentId, participant);
            }
        }