Esempio n. 1
0
        /// <summary>
        ///     Adds the course offering.
        /// </summary>
        /// <param name="courseOffering">The course offering.</param>
        public void AddCourseOffering(CourseOffering courseOffering)
        {
            using (_courseOfferingRepository)
            {
                if (_courseOfferingRepository.HasCourseOffering(courseOffering))
                    throw new CourseOfferingExistsException();

                _courseOfferingRepository.InsertCourseOffering(courseOffering);
            }
        }
 public void InsertCourseOffering(CourseOffering courseOffering)
 {
     using (var dbTransaction = _db.Database.BeginTransaction())
     {
         try
         {
             _db.CourseOfferings.Add(courseOffering);
             _db.SaveChanges();
             dbTransaction.Commit();
         }
         catch (Exception)
         {
             dbTransaction.Rollback();
         }
     }
 }
 /// <summary>
 ///     Check if a Course Offering exists
 /// </summary>
 /// <param name="courseOffering">The course offering.</param>
 /// <returns></returns>
 public bool HasCourseOffering(CourseOffering courseOffering) => _db.CourseOfferings.Any(
     offering =>
         offering.Semester == courseOffering.Semester && offering.Year == courseOffering.Year &&
         offering.CourseId == courseOffering.CourseId);