コード例 #1
0
        public bool Add(string emailAddress, Guid universityId)
        {
            //SRP
            Console.WriteLine(string.Format("Log: Start add student with email '{0}'", emailAddress));

            if (string.IsNullOrWhiteSpace(emailAddress))            //input validation
            {
                return(false);
            }

            var studentRepository = new _StudentRepository();      //DIP

            if (studentRepository.Exists(emailAddress))            //domain validation
            {
                return(false);
            }

            var universityRepository = new _UniversityRepository();

            var university = universityRepository.GetById(universityId);

            var student = new _Student(emailAddress, universityId);

            //SRP, OCP
            if (university.Package == _Package.Standard)
            {
                student.MonthlyEbookAllowance = 10;
            }
            else if (university.Package == _Package.Premium)
            {
                student.MonthlyEbookAllowance = 10 * 2;
            }

            studentRepository.Add(student);

            //SRP
            Console.WriteLine(string.Format("Log: End add student with email '{0}'", emailAddress));

            return(true);           //CQS
        }
コード例 #2
0
 public void Add(_Student student)
 {
     throw new NotImplementedException();
 }
コード例 #3
0
		public void Add(_Student student)
		{
			throw new NotImplementedException();
		}