예제 #1
0
        public ActionResult Apply(JOB_APPLICATION apply)
        {
            JobApplicationService service = new JobApplicationService();

            if (service.Create(apply))
            {
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
예제 #2
0
        public ActionResult Submit()
        {
            //get test index
            UsrService usrService = new UsrService();
            int        apply_id   = usrService.getApplyIdByUsername(Session["username"].ToString());
            int        index      = TestService.getIndexByApplyId(apply_id);
            var        endDate    = TestService.getEndTimeByApplyId(apply_id);

            //add additional time to ensure weak connection
            endDate.AddMinutes(2);
            if (DateTime.Compare(DateTime.Now, TestService.getStartTimeByApplyId(apply_id)) > 0 && DateTime.Compare(DateTime.Now, endDate) < 0)
            {
                //get question id list
                String result = Request.Params.Get("QuestionList").Trim();

                //convert result to list of string to iterator
                List <String> QuestionIds = result.Split(new char[] { ' ' }).ToList();
                List <String> AnswerLists = new List <string>();
                foreach (var i in QuestionIds)
                {
                    AnswerLists.Add(Request.Params.Get("Q[" + i + "]"));
                }

                //calculate result score
                double score = TestService.calculateScore(QuestionIds, AnswerLists, apply_id, index);
                AptechSem3.Service.ModelService.TestService        service    = new Service.ModelService.TestService();
                AptechSem3.Service.ModelService.ApplicationService appService = new Service.ModelService.ApplicationService();
                double total = (double)service.GetScoreFromTestAndCategory(appService.getTestIdByApplyId(apply_id.ToString()), "none");
                if (score >= total * 0.8)
                {
                    JOB_APPLICATION app = appService.findById(apply_id.ToString());
                    app.APPROVE_STATUS = 2;
                    appService.update(app);
                }
                else
                {
                    JOB_APPLICATION app = appService.findById(apply_id.ToString());
                    app.APPROVE_STATUS = -2;
                    appService.update(app);
                }
                //update index to 1
                index++;
                TestService.updateIndexByApplyId(apply_id, index);


                if (DateTime.Compare(DateTime.Now, TestService.getEndTimeByApplyId(apply_id)) > 0)
                {
                    return(RedirectToAction("finished", "Test"));
                }
                return(RedirectToAction("DoTest", "Test"));
            }
            return(RedirectToAction("finished", "Test"));
        }
예제 #3
0
        public ActionResult UpdateForm(JOB_APPLICATION apply)
        {
            JobApplicationService jobApplicationService = new JobApplicationService();

            if (jobApplicationService.update(apply))
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View("Apply", "Apply", new { id = apply.POST_ID }));
            }
        }
예제 #4
0
        public ActionResult ApplicationDetail(string applyId)
        {
            ApplicationService applicationService = new ApplicationService();
            JOB_APPLICATION    application        = applicationService.findById(applyId);
            TestService        testService        = new TestService();

            ViewBag.TestList = testService.findByPost(application.POST_ID);
            ViewBag.Test     = testService.findByPostSingle(application.POST_ID);
            UserService userService = new UserService();

            TempData["User"]        = userService.findReportByApplyId(applyId);
            TempData["Application"] = applicationService.findById(applyId);
            return(View());
        }
예제 #5
0
        public ActionResult ApplyForm(String PERSONAL_ID, String PHONE, int postId)
        {
            ViewBag.POST_ID     = postId;
            ViewBag.PHONE       = PHONE;
            ViewBag.PERSONAL_ID = PERSONAL_ID;
            JOB_APPLICATION application = JobApplicationService.findByPersonalIdAndPhone(PERSONAL_ID, PHONE);

            ViewBag.application = application;
            if (application == null)
            {
                return(View("ApplyForm"));
            }
            else
            {
                TempData["Application"] = application;
                return(View("UpdateForm"));
            }
        }
예제 #6
0
 //Mail the APPROVED candidates
 public ActionResult Mail(int APPLY_ID, int TEST_ID)
 {
     try
     {
         ResultService resultService = new ResultService();
         RESULT        result        = new RESULT();
         result.APPLY_ID = APPLY_ID;
         result.TEST_ID  = TEST_ID;
         //create result before mail
         resultService.create(result);
     }
     catch (Exception)
     {
     }
     try
     {
         //Mail
         AptechSem3.Service.MailService mailService  = new Service.MailService();
         ApplicationService             applyService = new ApplicationService();
         JOB_APPLICATION apply = applyService.findById(APPLY_ID.ToString());
         AptechSem3.Service.UsrService userService = new AptechSem3.Service.UsrService();
         USR         usr         = userService.findUsrByApplyID(APPLY_ID);
         TestService testService = new TestService();
         TEST        test        = testService.findById(TEST_ID.ToString());
         //message
         String message = "<p>Dear " + apply.NAME + ",</p>" +
                          "<p>Thank you for applying for the position with The Webster Company.</p>" +
                          "<p>We would like to invite you to our online test for the position. Your test has been scheduled for " + test.START_TIME + " to " + test.END_TIME + ".</p>" +
                          "<p>Your account for this test:</p>" +
                          "<p>Username: "******"</p>" + "<p>Password: "******"</p>" +
                          "<p>Please reply if you have any question.</p>" +
                          "<p>Sincerly,</p>" +
                          "<p>The Webster Company</p>";
         mailService.sendMail(apply.MAIL, test.TEST_NAME, message);
         ViewBag.error = "Mail success";
     }
     catch (Exception ex)
     {
         ViewBag.error = ex.Message;
     }
     return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = APPLY_ID }));
 }
예제 #7
0
 public static bool Validate(JOB_APPLICATION application)
 {
     if (!TextValidation.validateStringNumber(application.PERSONAL_ID))
     {
         return(false);
     }
     if (!TextValidation.validateStringNumber(application.PHONE))
     {
         return(false);
     }
     if (!TextValidation.validateStringDigit(application.NAME))
     {
         return(false);
     }
     if (!TextValidation.validateEmail(application.MAIL))
     {
         return(false);
     }
     return(true);
 }
예제 #8
0
 // GET: Test
 public ActionResult Index()
 {
     if (Session["username"] != null)
     {
         UsrService      usrService  = new UsrService();
         int             apply_id    = usrService.getApplyIdByUsername(Session["username"].ToString());
         JOB_APPLICATION application = JobApplicationService.findByUsername(Session["username"].ToString());
         ViewBag.Application = application;
         TEST test = TestService.getTestByApplyId(apply_id);
         ViewBag.Test = test;
         //if start time is later than now and end time is ealier than now let the candidate have link to do test
         if (DateTime.Compare(DateTime.Now, test.START_TIME) > 0 && DateTime.Compare(DateTime.Now, test.END_TIME) < 0)
         {
             ViewBag.link = TestService.getIndexByApplyId(apply_id);
         }
         //timer
         TimeSpan timeLeft = test.END_TIME - test.START_TIME;
         ViewBag.TimeLeft = timeLeft;
         return(View());
     }
     return(RedirectToAction("Login", "Home"));
 }
예제 #9
0
        //Approve Apps
        public ActionResult ApproveApplication(string applyId, int status)
        {
            ApplicationService applicationService = new ApplicationService();
            ResultService      resultService      = new ResultService();
            //Create a new Object APPLY TYPE
            JOB_APPLICATION apply       = new JOB_APPLICATION();
            PostService     postService = new PostService();
            //get TestId by ApplyId
            int testId = applicationService.getTestIdByApplyId(applyId);

            //testid == 0 equal testid == null
            if (testId == 0)
            {
                //redirect page
                return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = applyId }));
            }
            //find the APPLY with applyId
            apply = applicationService.findById(applyId);
            //get Now DateTime to compare
            string      created     = DateTime.Now.ToString("ddMMyyyyHHmmss");
            UserService userService = new UserService();

            //Check Apply Existed
            if (userService.findByApplyId(applyId))
            {
                ViewBag.error = "User has Existed";
                return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = applyId }));
            }
            //Check same status ?
            if (apply.APPROVE_STATUS == status)
            {
                ViewBag.error = "Can't proceed the same Status";
                return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = applyId }));
            }
            else
            //Status == 1 -> Status == "Approved"
            if (status == 1)
            {
                RESULT result = new RESULT();
                result.APPLY_ID = Int32.Parse(applyId);
                result.TEST_ID  = testId;


                applicationService.apply(applyId, 1);
                string username = "******" + created;
                string decrypt  = string.Join("", MD5.Create().ComputeHash(Encoding.ASCII.GetBytes(created)).Select(s => s.ToString("x2")));
                string password = decrypt.Substring(2, 10);
                USR    user     = new USR();
                user.APPLY_ID = Int32.Parse(applyId);
                user.ROLE     = "CANDIDATE";
                user.USERNAME = username;
                user.PASSWORD = password;
                //if create false => user existed
                if (userService.create(user))
                {
                    return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = applyId }));
                }
                else
                {
                    ViewBag.error = "User for this application existed";
                    return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = applyId }));
                }
            }
            else
            //unapprove
            {
                //check delete the result
                if (resultService.deleteResultByApply(Int32.Parse(applyId)))
                {
                }
                //unapprove the apply
                applicationService.apply(applyId, -1);
            }

            return(RedirectToAction("ApplicationDetail", "Manager", new { applyId = applyId }));
        }