public int Save() { CourseCreditsBLL cc = null; if (Key != null) { cc = CourseCreditsBLL.GetDetails(Key); if (cc == null) { throw new CourseCreditsException("Invalid Key."); } if (cc.UsedCredits < cc.TotalCredits) { EventID = cc.EventID; } else { throw (new CourseCreditsException("There are no credits left for this key.")); } } if (EventID > 0) { if (UserEnrolmentBLL.GetDetails(UserID, EventID).ID == 0) { AdminUserID = UserBLL.AdminID; ID = UserEnrolmentDAL.Save(UserID, EventID, AdminUserID, (cc.ID > 0) ? "s" : "a", "v", cc.ID); if (ID > 0 && cc != null) { cc++; } } else { throw new UserEnrolException("This user is already enrolled on this event."); } } else { throw (new UserEnrolException("Must include valid EventID or Credit Key")); } return(ID); }