Ejemplo n.º 1
0
        public ActionResult Create()
        {
            ApplicationFormViewModel viewModel =
                _applicationManagementService.CreateFormViewModel();

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Create(Application application)
        {
            if (ViewData.ModelState.IsValid)
            {
                application.LastUpdateTimeStamp = DateTime.Now;
                application.LastUpdateUser      = GetCurrentUser().Id;
                ActionConfirmation saveOrUpdateConfirmation =
                    _applicationManagementService.SaveOrUpdate(application);

                if (saveOrUpdateConfirmation.WasSuccessful)
                {
                    TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
                        saveOrUpdateConfirmation.Message;
                    return(RedirectToAction("Index"));
                }
            }
            else
            {
                application = null;
            }

            ApplicationFormViewModel viewModel =
                _applicationManagementService.CreateFormViewModelFor(application);

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public ApplicationFormViewModel CreateFormViewModel()
        {
            var viewModel = new ApplicationFormViewModel();

            LoadViewModel(viewModel);
            return(viewModel);
        }
Ejemplo n.º 4
0
        public ApplicationFormViewModel CreateFormViewModelFor(Application application)
        {
            ApplicationFormViewModel viewModel = new ApplicationFormViewModel();

            application.SetHostIdsFromHost();
            viewModel.Application = application;
            LoadViewModel(viewModel);
            if (application.SupportTeamId != null)
            {
                viewModel.SupportTeam = _supportTeamManagementService.Get(application.SupportTeamId.Value);
                if (viewModel.SupportTeam != null && viewModel.SupportTeam.SupervisorId.HasValue)
                {
                    viewModel.SupportTeamSupervisor = _personManagementService.Get(viewModel.SupportTeam.SupervisorId.Value);
                }
                if (viewModel.SupportTeamSupervisor != null && viewModel.SupportTeamSupervisor.SupervisorId.HasValue)
                {
                    viewModel.SupportTeamAdmin = _personManagementService.Get(viewModel.SupportTeamSupervisor.SupervisorId.Value);
                }
            }
            if (application.SubjectMatterExpertId != null)
            {
                viewModel.SubjectMatterExpert = _personManagementService.Get(application.SubjectMatterExpertId.Value);
            }
            return(viewModel);
        }
        public void CannotUpdateInvalidApplicationFromForm()
        {
            // Establish Context
            var applicationFromForm = new Application();
            var viewModelToExpect   = new ApplicationFormViewModel();

            var testUser = PersonInstanceFactory.CreateValidTransientPerson();

            testUser.SetAssignedIdTo(1);
            _authenticationProvider.Expect(r => r.GetLoggedInUser()).Return("testuser");
            _personManagementService.Expect(r => r.GetByUserName(Arg <string> .Is.Anything)).Return(testUser);

            _applicationManagementService.Expect(r => r.UpdateWith(applicationFromForm, 0))
            .Return(ActionConfirmation.CreateFailureConfirmation("not updated"));
            _applicationManagementService.Expect(r => r.CreateFormViewModelFor(applicationFromForm))
            .Return(viewModelToExpect);

            // Act
            ViewResult result =
                _applicationsController.Edit(applicationFromForm).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ApplicationFormViewModel).ShouldNotBeNull();
        }
        public ActionResult Edit(ApplicationFormViewModel viewModel, string command)
        {
            if (ModelState.IsValid)
            {
                PromotionResult promotionResult = new PromotionResult();

                if (command == "Save")
                {
                    promotionResult.Success = true;
                    promotionResult.Message = String.Format("Changes to Leave Application {0} have been successfully saved.", viewModel.Id);
                }
                else if (command == "Forward")
                {
                    promotionResult = viewModel.ClaimWorkListItem(User.Identity.GetUserId());
                }
                else
                {
                    promotionResult = viewModel.PromoteWorkListItem(command);
                }

                ApplicationForm applicationForm = Mapper.Map <ApplicationForm>(viewModel);
                applicationForm.CompanyId = CompanyCookie.CompId;
                _dbContext.Entry(applicationForm).State = EntityState.Modified;
                _dbContext.SaveChanges();

                return(RedirectToAction("Index"));
            }
            return(View(viewModel));
        }
Ejemplo n.º 7
0
        public IActionResult Index(int id)
        {
            var project                  = _projects.GetProjectById(id);
            var projectViewModel         = new ProjectViewModel(project);
            var applicationFormViewModel = new ApplicationFormViewModel(projectViewModel);

            return(View(applicationFormViewModel));
        }
        public ActionResult Create()
        {
            ViewBag.EmployeeId = new SelectList(_dbContext.Contacts, "Id", "FullName");
            ApplicationFormViewModel viewModel = new ApplicationFormViewModel();

            viewModel.CurrentDate = DateTime.Now.Date;
            return(View(viewModel));
        }
Ejemplo n.º 9
0
        protected void LoadViewModel(ApplicationFormViewModel viewModel)
        {
            viewModel.SubjectMatterExperts = (viewModel.Application != null &&
                                              viewModel.Application.SubjectMatterExpertId.HasValue)
                                        ? _personManagementService.GetActiveStaff(viewModel.Application.SubjectMatterExpertId.Value)
                                        : _personManagementService.GetActiveStaff();

            viewModel.Hosts        = _hostManagementService.GetAll();
            viewModel.SupportTeams = _supportTeamManagementService.GetAll();
        }
        public void Constructor_WithProjectViewModel_SetsSubMenuViewModelPageToApplicationForm()
        {
            var project = new Project {
                School = new School(), Trust = new Trust()
            };
            var projectViewModel         = new ProjectViewModel(project);
            var applicationFormViewModel = new ApplicationFormViewModel(projectViewModel);

            applicationFormViewModel.SubMenu.Page.Should().Be(SubMenuPage.ApplicationForm);
        }
Ejemplo n.º 11
0
        public void CanCreateFormViewModel()
        {
            // Establish Context
            var viewModelToExpect = new ApplicationFormViewModel();

            // Act
            ApplicationFormViewModel viewModelRetrieved =
                _applicationManagementService.CreateFormViewModel();

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.Application.ShouldBeNull();
        }
        public void Constructor_WithProjectViewModel_SetsNavigationViewModelToProjectsListContentAndUrl()
        {
            var project = new Project {
                School = new School(), Trust = new Trust()
            };
            var projectViewModel         = new ProjectViewModel(project);
            var applicationFormViewModel = new ApplicationFormViewModel(projectViewModel);
            var expectedContent          = "Back to all conversion projects";
            var expectedUrl = "/projectlist";

            applicationFormViewModel.Navigation.Content.Should().Be(expectedContent);
            applicationFormViewModel.Navigation.Url.Should().Be(expectedUrl);
        }
Ejemplo n.º 13
0
        public ActionResult ApplicationForm(ApplicationFormViewModel applicationForm,
                                            HttpPostedFileBase file1, HttpPostedFileBase file2)
        {
            try
            {
                if (file2.ContentLength > 0 && file1.ContentLength > 0)
                {
                    String FileExt1 = Path.GetExtension(file1.FileName).ToUpper();
                    String FileExt2 = Path.GetExtension(file2.FileName).ToUpper();

                    if (FileExt1 == ".PDF" && FileExt2 == ".PDF")
                    {
                        applicationForm.CV     = file1;
                        applicationForm.Letter = file2;
                        if (ModelState.IsValid)
                        {
                            var res = ijobApplication.SubmitApplication(applicationForm, file2.FileName, UserId, file1.FileName);
                            if (res == "Success")
                            {
                                ViewBag.ModelMessage = "Submit Succesfull";
                            }
                            else
                            {
                                ViewBag.ModelMessage = "Submit Unuccesfull";
                            }
                        }
                        else
                        {
                            ViewBag.ModelMessage = "Empty fields";
                            ModelState.AddModelError("", "Empty Feilds");
                            return(View(applicationForm));
                        }
                    }
                    else
                    {
                        ViewBag.FileStatus = "Invalid file format.";
                        return(View());
                    }
                }
                else
                {
                    ViewBag.ModelMessage = "Please Upload a CV And Letter";
                    return(View(applicationForm));
                }
            }
            catch (Exception e)
            {
                ViewBag.ModelMessage = "ERROR:  " + e.Message.ToString();
            }
            return(View());
        }
Ejemplo n.º 14
0
        //this method submits applicants form to the database and notifies the Admin that posted the job.
        public string SubmitApplication(ApplicationFormViewModel applicationForm, string NameLetter
                                        , string userid, string NameCV)
        {
            string result = "";

            try
            {
                Applications newApplications = new Applications()
                {
                    FirstName   = applicationForm.FirstName,
                    OtherNames  = applicationForm.OtherNames,
                    LastName    = applicationForm.LastName,
                    Address     = applicationForm.Address,
                    Phonenumber = applicationForm.Phonenumber,
                    State       = applicationForm.State,
                    JobID       = applicationForm.JobID,
                    UserId      = userid,
                    Email       = applicationForm.Email,
                    NameCV      = NameCV,
                    NameLetter  = NameLetter,
                    CV          = JobApplicationServices.ConvertToByte(applicationForm.CV),
                    Letter      = JobApplicationServices.ConvertToByte(applicationForm.Letter),
                    DateCreated = DateTime.Now,
                };

                string HTMLcontent = "This is to inform you that <b>" + applicationForm.FirstName
                                     + " " + applicationForm.LastName + "</b> Has applied for the job offer you posted on JB Limited";

                var res = isendMail.SendMail(
                    "*****@*****.**",
                    iadmin.GetAdminEmail(applicationForm.JobID),
                    "NEW APPLICANT",
                    HTMLcontent
                    );
                if (res.IsCompleted)
                {
                    dbContext.applications.Add(newApplications);
                    dbContext.SaveChanges();
                    result = "Success";
                }
                else
                {
                    result = "An internal Error Occured. Please check you Network";
                }
            }
            catch (Exception e)
            {
                result = "Error: " + e.Message;
            }
            return(result);
        }
        public ActionResult Create(ApplicationFormViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                ApplicationForm applicationForm = Mapper.Map <ApplicationForm>(viewModel);
                applicationForm.Id        = Guid.NewGuid();
                applicationForm.CompanyId = CompanyCookie.CompId;
                _dbContext.ApplicationForms.Add(applicationForm);
                _dbContext.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(viewModel));
        }
        public void CanInitCreate()
        {
            // Establish Context
            var viewModel = new ApplicationFormViewModel();

            _applicationManagementService.Expect(r => r.CreateFormViewModel())
            .Return(viewModel);

            // Act
            ViewResult result = _applicationsController.Create().AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ApplicationFormViewModel).ShouldNotBeNull();
            (result.ViewData.Model as ApplicationFormViewModel).Application.ShouldBeNull();
        }
Ejemplo n.º 17
0
        //gets Applicants details to put in application form for easier applicaton
        public ApplicationFormViewModel GetApplicantsDetails(string userId)
        {
            var a = dbContext.applicants.Where(o => o.UserId == userId).FirstOrDefault();
            ApplicationFormViewModel m = new ApplicationFormViewModel()
            {
                FirstName   = a.FirstName,
                OtherNames  = a.OtherNames,
                LastName    = a.LastName,
                Address     = a.Address,
                Phonenumber = a.Phonenumber,
                State       = a.State,
                Email       = a.Email,
            };

            return(m);
        }
Ejemplo n.º 18
0
        public ActionResult Edit(int id)
        {
            ApplicationFormViewModel viewModel =
                _applicationManagementService.CreateFormViewModelFor(id);
            Person user = GetCurrentUser();

            switch (user.RoleId)
            {
            case 2:     //Supervisor
                return(View(viewModel));

            case 3:     //Analyst
                return(View("SupportStaffEdit", viewModel));

            default:     // Service Desk
                return(View("ServiceDeskEdit", viewModel));
            }
        }
Ejemplo n.º 19
0
        public void CanCreateFormViewModelForApplication()
        {
            // Establish Context
            var viewModelToExpect = new ApplicationFormViewModel();

            Application application =
                ApplicationInstanceFactory.CreateValidTransientApplication();

            _applicationRepository.Expect(r => r.Get(1))
            .Return(application);

            // Act
            ApplicationFormViewModel viewModelRetrieved =
                _applicationManagementService.CreateFormViewModelFor(1);

            // Assert
            viewModelRetrieved.ShouldNotBeNull();
            viewModelRetrieved.Application.ShouldNotBeNull();
            viewModelRetrieved.Application.ShouldEqual(application);
        }
        public void CanShowApplication()
        {
            // Establish Context
            Application application =
                ApplicationInstanceFactory.CreateValidTransientApplication();
            var viewModel = new ApplicationFormViewModel {
                Application = application
            };

            _applicationManagementService.Expect(r => r.CreateFormViewModelFor(Arg <int> .Is.Anything))
            .Return(viewModel);

            // Act
            ViewResult result = _applicationsController.Show(1).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ApplicationFormViewModel).Application.ShouldNotBeNull();
            (result.ViewData.Model as ApplicationFormViewModel).Application.ShouldEqual(application);
        }
        public void CanInitEdit()
        {
            // Establish Context
            var viewModel = new ApplicationFormViewModel();

            _applicationManagementService.Expect(r => r.CreateFormViewModelFor(Arg <int> .Is.Anything))
            .Return(viewModel);

            var testUser = PersonInstanceFactory.CreateValidTransientPerson();

            testUser.SetAssignedIdTo(1);
            _authenticationProvider.Expect(r => r.GetLoggedInUser()).Return("testuser");
            _personManagementService.Expect(r => r.GetByUserName(Arg <string> .Is.Anything)).Return(testUser);

            // Act
            ViewResult result = _applicationsController.Edit(1).AssertViewRendered();

            // Assert
            result.ViewData.Model.ShouldNotBeNull();
            (result.ViewData.Model as ApplicationFormViewModel).ShouldNotBeNull();
        }
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ApplicationForm          applicationForm = _dbContext.ApplicationForms.Find(id);
            ApplicationFormViewModel viewModel       = Mapper.Map <ApplicationFormViewModel>(applicationForm);

            if (applicationForm == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(_dbContext.Contacts, "Id", "FullName", applicationForm.EmployeeId);

            if (viewModel.Status.Substring(viewModel.Status.Length - 3, 3) != "ing")
            {
                return(View("Forward", viewModel));
            }

            return(View(viewModel.Status, viewModel));
        }
Ejemplo n.º 23
0
        public ActionResult Index()
        {
            if (TempData.ContainsKey("accessToken"))
            {
                if (TempData["accessToken"].ToString() == "Granted")
                {
                    var applicantId        = Convert.ToInt32(TempData["applicantId"]);
                    var applicantQuestions = _applicantsQuestionsDataAccess.GetAllQuestions(applicantId);

                    var formResponse = new FormResponse
                    {
                        ApplicantId          = applicantId,
                        FormResponseContents = new List <FormResponseContent>()
                    };
                    var viewModel = new ApplicationFormViewModel
                    {
                        ApplicantQuestions = applicantQuestions,
                        FormResponse       = formResponse
                    };
                    return(View(viewModel));
                }
            }
            return(RedirectToAction("Auth"));
        }
Ejemplo n.º 24
0
        public ActionResult Save(ApplicationFormViewModel applicationFormViewModel, HttpPostedFileBase uploadFile)
        {
            ////I commented it coz it will always give an error as resume field is required
            //if (!ModelState.IsValid)
            //{
            //    ViewBag.ErrorMsg = "Something went wrong with your submission. Please try again later";
            //    return View("Error");
            //}

            applicationFormViewModel.FormResponse.SubmissionDate  = DateTime.Now;
            applicationFormViewModel.FormResponse.Status          = ApplicationFormResponseStatus.NotViewed;
            applicationFormViewModel.FormResponse.ApplicantResume = "#"; // HACK: coz resume is required and not yet created
            _formResponsesDataAccess.CreateResponse(applicationFormViewModel.FormResponse);

            var applicant = _applicantsDataAccess.GetApplicantById(applicationFormViewModel.FormResponse.ApplicantId);

            if (applicant != null)
            {
                applicant.Status = ApplicantStatus.ApplicationSubmitted;
                if (uploadFile != null)
                {
                    var serverPath = Server.MapPath("~/Uploads/");
                    if (!Directory.Exists(serverPath))
                    {
                        Directory.CreateDirectory(serverPath);
                    }
                    var extension = Path.GetExtension(uploadFile.FileName)?.ToLower();
                    if (extension != ".pdf")
                    {
                        ViewBag.ErrorMsg = "Invalid file type - Need to be PDF";
                        return(View("Error"));
                    }
                    var filePath = Path.Combine(serverPath + Path.GetFileName(uploadFile.FileName));
                    uploadFile.SaveAs(filePath);

                    var applicantName = string.Join("", applicant.Name.Split(' '));
                    var fileName      = applicant.Id.ToString() + '.' + applicantName + ".pdf";
                    applicant.FormResponse.ApplicantResume = _blobServices.BlobUrl + "resumes/" + fileName;
                    _applicantsDataAccess.SaveChangesToDb();

                    _blobServices.BlobMediaUpload(fileName, filePath, "resumes");


                    // Delete file from server after finishing
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    System.IO.File.Delete(filePath);
                }
                _applicantsDataAccess.SaveChangesToDb();
            }
            else
            {
                ViewBag.ErrorMsg = "Can't find applicant data in our system to submit it. " +
                                   "Please contact system administrator if you think this is a mistake";
                return(View("Error"));
            }



            return(View("Success"));
        }