Exemple #1
0
        public void TestAppStatus()
        {
            var        context = new Entity.K_12Entities();
            UnitOfWork uw      = new UnitOfWork(context);

            Entity.Application a = uw.Applications.Find(11);
            a.app_status = "Waiting";
            uw.Applications.Update(a);
            uw.Save();
            Assert.AreEqual(uw.Applications.Find(11).app_status, "Waiting");
        }
        public ActionResult StudentInfo()
        {
            if (CurrentAppID != null)
            {
                Entity.Application app = _unitOfWork.Applications.Find(CurrentAppID);

                if (app != null)
                {
                    return(View(new Models.Admission.StudentInfoViewModel()
                    {
                        FName = app.Applicant.FName, MName = app.Applicant.MName, Gender = app.Applicant.Gender, DOB = app.Applicant.DOB
                    }));
                }
            }
            return(View());
        }
        public async Task <ActionResult> SetStatus(Entity.Application app, string ButtonType)
        {
            var updatedApp = _applicationService.Find(app.ID);

            if (BLL.Constants.ApplicationStatuses.avarailbleStatuses.Contains(ButtonType))
            {
                updatedApp.app_status = ButtonType;
                _applicationService.Update(updatedApp);

                try
                {
                    await _unitOfWork.SaveAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                }
            }

            return(PartialView("ApplicationDetail", updatedApp));
        }
Exemple #4
0
        public ActionResult ApplicationResult(int appID)
        {
            Entity.Application app = _unitOfWork.Applications.Find(appID);
            Models.ApplicationRessultViewModel resultViewModel = new Models.ApplicationRessultViewModel();

            if (app != null)
            {
                resultViewModel.AppFound  = true;
                resultViewModel.AppStatus = app.app_status;
                resultViewModel.AppID     = app.ID;


                if (app.app_status == BLL.Constants.ApplicationStatuses.ACCEPTED)
                {
                    return(View("ApplicationAccepted", resultViewModel));
                }
            }


            return(View(resultViewModel));
        }
        public async Task <ActionResult> Confirmation(string ButtonType)
        {
            if (ButtonType == "Next")
            {
                ApplicationDbContext context = new ApplicationDbContext();

                var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context));

                var user = new ApplicationUser {
                    UserName = CurrentUserModel.Username, Email = CurrentUserModel.Email, DisplayName = CurrentStudent.Parents.First().Parent.GetFullName()
                };


                var result = await UserManager.CreateAsync(user, CurrentUserModel.Password);

                if (result.Succeeded)
                {
                    UserManager.AddToRole(user.Id, "Parent");
                    CurrentStudent.Parents.First().Parent.user_id = user.Id;

                    ApplicationSignInManager SignInManager = HttpContext.GetOwinContext().Get <ApplicationSignInManager>();
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);



                    CurrentStudent.Languages.Clear();

                    foreach (string lan_id in StudentExtraInfoModel.Languages)
                    {
                        CurrentStudent.Languages.Add(_unitOfWork.Languages.Find(lan_id));
                    }

                    if (CurrentAppID != null)
                    {
                        Entity.Application app = _unitOfWork.Applications.Find(CurrentAppID);
                        app.app_status = BLL.Constants.ApplicationStatuses.ADMITED;
                        _unitOfWork.Applications.Update(app);
                        CurrentStudent.Applications.Add(app);
                    }



                    _unitOfWork.Students.Add(CurrentStudent);

                    try
                    {
                        await _unitOfWork.SaveAsync();
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                    }



                    return(View("FinishAdmission", new Models.Admission.SuccessAdmissionViewModel()
                    {
                        Email = user.Email,
                        UserName = user.UserName,
                        StudentFullName = CurrentStudent.GetFullName(),
                        ParentFullName = CurrentStudent.Parents.First().Parent.GetFullName(),
                        Relation = CurrentStudent.Parents.First().Relation
                    }));
                }
            }


            else if (ButtonType == "Back")
            {
                return(View("UserRegistration", CurrentUserModel));
            }



            return(View());
        }
Exemple #6
0
        public ActionResult Confirmation(Models.FileUploadViewModel files, string ButtonType)
        {
            // return PartialView("Confirmation", app);

            Entity.Applicant currentApplicant = GetApplicant();
            if (ButtonType == "Back")
            {
                return(View("DocumentUpload", GetDocuments()));
            }


            if (ButtonType == "Next")
            {
                ICollection <Models.FileUploadViewModel> applicantDocuments = GetDocuments();


                //// The files are not actually saved in this demo
                //file.SaveAs(physicalPath);



                //TODO save to db
                try
                {
                    _service.Insert(currentApplicant);
                    _unitOfWork.Save(); //to get the autogenerated id

                    Entity.Application currentApplication = new Entity.Application()
                    {
                        application_date = DateTime.Today, grade_applying_id = SelectedGrade.ID
                    };

                    foreach (var doc in applicantDocuments)
                    {
                        if (doc.FileName != null)
                        {
                            string localPath = Path.Combine(currentApplicant.ID.ToString(), currentApplication.application_date.Value.ToString("dd-MM-yyyy"));

                            string physicalPath = Path.Combine(Server.MapPath("~/App_Data"), localPath);

                            Directory.CreateDirectory(physicalPath);

                            string tempPath = Path.Combine(Server.MapPath("~/App_Data/Temp"), doc.FileName);

                            physicalPath += "\\" + doc.Type + doc.Extention;

                            System.IO.File.Move(tempPath, physicalPath);

                            string localFilePath = localPath + "\\" + doc.Type + doc.Extention;
                            currentApplication.Documents.Add(new Entity.Document()
                            {
                                type = doc.Type, Doc_path = localFilePath, IsVerified = false
                            });
                        }
                    }
                    currentApplication.app_status = BLL.Constants.ApplicationStatuses.PENDING;

                    currentApplicant.Applications.Add(currentApplication);
                    _service.Update(currentApplicant); //to update documet path
                    _unitOfWork.Save();
                }

                catch (DbUpdateConcurrencyException)
                {
                    //TO-DO catch db eror
                }

                Entity.Application app = currentApplicant.Applications.Last();
                if (BLL.BLL.Configuration.AdmisssionMethod == BLL.Constants.AdmissionMethods.FIFO)
                {
                    //if a place is available
                    app.app_status = BLL.Constants.ApplicationStatuses.ACCEPTED;
                    _unitOfWork.Applications.Update(app);
                    _unitOfWork.Save();
                    return(ApplicationResult(app.ID));
                }
                ViewBag.appId = app.ID;
                return(View("FinishPage"));
            }


            return(View());
        }