예제 #1
0
        public bool RemoveCourse(CourseTO courseTo)
        {
            if (courseTo is null)
            {
                throw new ArgumentNullException(nameof(courseTo));
            }

            if (courseTo.Id == 0)
            {
                throw new Exception("Course does not exist");
            }

            try
            {
                iRSUnitOfWork.CourseRepository.Remove(courseTo.ToDomain().ToTransfertObject());
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public bool UpdateCourse(CourseTO courseTo)
        {
            if (courseTo is null)
            {
                throw new ArgumentNullException(nameof(courseTo));
            }
            if (courseTo.Id == 0)
            {
                throw new Exception("Course does not exist");
            }

            courseTo.Name.IsNullOrWhiteSpace("Missing Course Name");

            try
            {
                iRSUnitOfWork.CourseRepository.Update(courseTo.ToDomain().ToTransfertObject());
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        public bool AddCourse(CourseTO courseTo)
        {
            if (courseTo is null)
            {
                throw new ArgumentNullException(nameof(courseTo));
            }
            if (courseTo.Id != 0)
            {
                throw new Exception("Existing Course");
            }

            courseTo.Name.IsNullOrWhiteSpace("Missing course name");

            try
            {
                iRSUnitOfWork.CourseRepository.Add(courseTo.ToDomain().ToTransfertObject());
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }