public void RemoveApplication(List<Domain.Context.Application> applicationList)
        {
            if (applicationList == null)
                throw new ArgumentNullException("applicationList");

            using (ApplicationRepository appRepository = new ApplicationRepository())
            {
                for (int i = 0; i < applicationList.Count; i++)
                {
                    appRepository.Remove(applicationList[i]);
                }
                appRepository.Commit();
            }
        }
        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
                    }
                }
            }
        }
        public void UpdateApplication(List<Domain.Context.Application> applicationList)
        {
            if (applicationList == null)
                throw new ArgumentNullException("applicationList");

            ApplicationRepository appRepository = new ApplicationRepository();
            for (int i = 0; i < applicationList.Count; i++)
            {
                // TODO: check if exists, priority low
                appRepository.Modify(applicationList[i]);
            }
            appRepository.Commit();
        }
        public void CreateApplicationTest()
        {
            ApplicationService target = new ApplicationService();
            UniversityAppService universitySerivce = new UniversityAppService();

            ApplicationRepository appRepository = new ApplicationRepository();
            var app = appRepository.Get(new Guid("6079D394-C27A-4871-996A-AC9374097042"));
            if (app != null)
            {
                appRepository.Remove(app);
                appRepository.Commit();
                app = appRepository.Get(new Guid("6079D394-C27A-4871-996A-AC9374097042"));
                Assert.AreEqual(app, null);
            }
            GF.Domain.Context.Application application = new Domain.Context.Application(new Guid("D1111C18-A0BD-480B-99CA-AAF50B2D1818"), new Guid("408AD727-5E75-409C-A658-0AB0C6A9EFD2"), new Guid("6079D394-C27A-4871-996A-AC9374097042"));
            target.CreateApplication(application);
            app = appRepository.Get(new Guid("6079D394-C27A-4871-996A-AC9374097042"));
            Assert.AreNotEqual(app, null);
            Assert.AreEqual(app.Id, new Guid("6079D394-C27A-4871-996A-AC9374097042"));
        }