Пример #1
0
        public void AddApplication()
        {
            var logger = new Mock <ILogger <ApplicationRepository> >();

            ApplicationRepository repository = new ApplicationRepository(context, logger.Object);
            Application           app        = new Application()
            {
                ApplicationName = "Application Two"
            };

            bool result = repository.AddApplication(app);

            Assert.AreEqual(true, result);
        }
Пример #2
0
        public ActionResult Apply(ApplicationViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Save PDF File
                string resumeFileName = _fileUtility.SaveResume(model.Resume);

                // Add User
                User user = new User {
                    Email    = model.Email,
                    Password = model.Password,
                    Role     = "student"
                };

                int?userId = _userRepository.AddStudent(user);

                if (userId != null)
                {
                    DataAccess.Application applicationModel = new DataAccess.Application
                    {
                        UserId         = (int)userId,
                        FirstName      = model.FirstName,
                        LastName       = model.LastName,
                        BirthDate      = model.BirthDate.ToShortDateString(),
                        NationalId     = model.NationalId,
                        University     = model.University,
                        Major          = model.Major,
                        GPA            = model.GPA,
                        ResumeFileName = resumeFileName,
                        IsAccepted     = null
                    };

                    int?applicationId = _applicationRepository.AddApplication(applicationModel);

                    if (applicationId != null)
                    {
                        // Do something when submitted
                        TempData["SubmitSuccess"] = "True";
                        return(RedirectToAction("Index", "Home"));
                    }
                }
            }

            TempData["SubmitError"] = "True";
            return(View());
        }