public void CreateApplication(Domain.Context.Application application)
        {
            if (application == null)
                throw new ArgumentNullException("application");

            using (UserRepository userRepository = new UserRepository())
            {
                var user = userRepository.Get(application.UserId);

                if (user != null)
                {
                    var achievement = user.Achievements.SingleOrDefault<Achievement>(a => a.Year == DateTime.Now.Year);
                    if (achievement != null)
                    {
                        //using (SpecialityEnrollPlanRepository enrollPlanRepository = new SpecialityEnrollPlanRepository())
                        //{
                        //    var enrollPlans = enrollPlanRepository.GetFiltered(e => e.SpecialityId == application.SpecialityId && e.Province == achievement.Province).SingleOrDefault<SpecialityEnrollPlan>();
                        //    if (enrollPlans != null)
                        //    {
                        using (ApplicationRepository appRepository = new ApplicationRepository())
                        {
                            var apps = appRepository.GetFiltered(app => app.Year == application.Year && app.Batch == application.Batch && app.ApplicationSequence == application.ApplicationSequence);
                            if (apps != null && apps.ToList<Domain.Context.Application>().Count > 0)
                            {
                                // throw existing application exception
                                throw new UniversityApplicationExistException(Resource.UserMessages.ex_UniversityApplicationExist);
                            }
                            appRepository.Add(application);
                            appRepository.Commit();
                        }
                        //}
                        //else
                        //{
                        //    // throw no enroll plan exception
                        //    throw new UniversityNoEnrollPlanException(Resource.ResourceMessage.ex_UnversityNoEnrollPlan);
                        //}
                        //}
                    }
                    else
                    {
                        throw new UniversityApplicationExistException(Resource.UserMessages.ex_AchievementNotExist);
                    }
                }
            }
        }
        public void CreateApplication(Domain.Context.Application application)
        {
            if (application == null)
                throw new ArgumentNullException("application");

            AccountRepository accountRepository = new AccountRepository();
            var account = accountRepository.Get(application.UserId);

            if (account != null)
            {
                var achievement = account.Achievements.ToList<Achievement>().SingleOrDefault<Achievement>( a=> a.Year.Year == DateTime.Now.Year);
                if (achievement != null)
                {
                    EnrollPlanRepository enrollPlanRepository = new EnrollPlanRepository();
                    var enrollPlans = enrollPlanRepository.GetFiltered(e => e.SpecialityId == application.SpecialityId && e.Province == achievement.Province).SingleOrDefault<EnrollPlan>();
                    if (enrollPlans != null)
                    {
                        ApplicationRepository appRepository = new ApplicationRepository();

                        var apps = appRepository.GetFiltered(app => app.Year.Year == application.Year.Year && app.Batch == application.Batch && app.ApplicationSequence == application.ApplicationSequence);
                        if (apps != null && apps.ToList<Domain.Context.Application>().Count > 0)
                        {
                            // TODO: throw existing application exception
                        }

                        appRepository.Add(application);
                        appRepository.Commit();
                    }
                    else
                    {
                        // TODO: throw no enroll plan exception
                    }
                }
            }
        }