Пример #1
0
        public void SuspendUser(int userID, DateTime since)
        {
            Ban ban = new Ban
            {
                UserID = userID,
                Until  = since
            };

            _context.Add(ban);
            _context.SaveChanges();
        }
Пример #2
0
        private void Create(int studentID, string teacherName, string message, string subjectTitle)
        {
            string studentName = GetStudentNameById(studentID);
            string validationMessage;
            bool   isValid = ValidateData(studentName, teacherName, message, subjectTitle, out validationMessage);

            if (isValid)
            {
                Question question = new Question
                {
                    TeacherName  = Encryptor.Encrypt(teacherName),
                    Message      = message,
                    StudentName  = studentName,
                    Answer       = "Not answered yet",
                    Status       = 0,
                    SubjectTitle = subjectTitle
                };

                _context.Add(question);
                _context.SaveChanges();
            }
            else
            {
                throw new ArgumentException(validationMessage);
            }
        }
Пример #3
0
        private void Create(string username, string password, string profession)
        {
            User user = new User
            {
                Nick       = Encryptor.Encrypt(username),
                Password   = Encryptor.Encrypt(password),
                Profession = profession,
            };

            _context.Add(user);
            _context.SaveChanges();
        }