public ActionResult Assigner(int idJobRequest, int idUser)
        {
            JobRequest jobrequest = serviceJobRequest.GetAll().Where(a => a.jobRequestId == idJobRequest && a.userId == idUser).SingleOrDefault();

            Folder folder = serviceFolder.GetAll().Where(a => a.jobRequestId == idJobRequest).SingleOrDefault();

            folder.state = "Assign";
            folder.etape = 4;
            serviceFolder.Update(folder);
            serviceFolder.Commit();

            return(RedirectToAction("listOffers", "JobRequest"));
        }
Exemplo n.º 2
0
        public ActionResult passerTest(QuestionList model)
        {
            List <Test> lists = new List <Test>();

            try {
                foreach (var item in model.tests)
                {
                    //test.testId = item.testId;
                    //int id = test.testId;
                    //test.IsCheckedR = item.IsCheckedR;
                    //test.IsCheckedR1 = item.IsCheckedR1;
                    //test.IsCheckedR2 = item.IsCheckedR2;

                    if ((item.IsCheckedR && item.IsCheckedR2) || (item.IsCheckedR && item.IsCheckedR1) || (item.IsCheckedR1 && item.IsCheckedR2))
                    {
                        error = "vous devez cochez seul reponse";
                        return(RedirectToAction("passerTest", "Test"));
                    }
                    else
                    {
                        if (item.IsCheckedR)
                        {
                            //  sb.Append(item.reponse + ",");



                            item.IsCheckedR = false;
                            Test tes = new Test();
                            tes.question = item.reponse;
                            tes.type     = item.type;
                            tes.testId   = item.testId;
                            tes.choix2   = item.reponse;
                            lists.Add(tes);
                        }
                        if (item.IsCheckedR1)
                        {
                            //   sb1.Append(item.choix1 + ",");


                            item.IsCheckedR1 = false;

                            Test tes = new Test();
                            tes.question = item.reponse;
                            tes.type     = item.type;
                            tes.testId   = item.testId;
                            tes.choix2   = item.choix1;
                            lists.Add(tes);
                        }


                        if (item.IsCheckedR2)
                        {
                            //                   sb2.Append(item.choix2 + ",");


                            item.IsCheckedR2 = false;
                            Test tes = new Test();
                            tes.question = item.reponse;
                            tes.type     = item.type;
                            tes.testId   = item.testId;
                            tes.choix2   = item.choix2;
                            lists.Add(tes);
                        }
                    }
                }
                List <Test> lists1 = lists.OrderBy(a => a.testId).ToList();

                for (int i = 0; i <= lists1.Count() - 1; i++)
                {
                    Answers ans = new Answers();

                    // ans.Test.testId = lists[i].testId;
                    ans.answer = lists[i].choix2;
                    ans.idTest = lists[i].testId;
                    ans.idUser = User.Identity.GetUserId <int>();
                    serviceAnswer.Add(ans);
                    serviceAnswer.Commit();
                }

                List <Answers> listAnswers = serviceAnswer.getListAnswers(User.Identity.GetUserId <int>()).OrderBy(a => a.idTest).ToList();


                int noteTest = 0;
                for (int i = 0; i <= lists1.Count() - 1; i++)
                {
                    if (listAnswers[i].answer.Equals(lists1[i].question))
                    {
                        noteTest = noteTest + 1;
                    }

                    serviceAnswer.Delete(listAnswers[i]);
                    serviceAnswer.Commit();
                    //  listAnswers.Remove(listAnswers[i]);
                }


                Folder folder = serviceFolder.getFolderByUser(User.Identity.GetUserId <int>());
                if (noteTest < lists.Count() / 2)
                {
                    folder.state      = "Refused";
                    folder.testResult = noteTest;
                    serviceFolder.Update(folder);
                    serviceFolder.Commit();
                }
                else
                {
                    folder.testResult = noteTest;
                    folder.typeTest   = lists[1].type;
                    folder.etape      = folder.etape + 1;

                    serviceFolder.Update(folder);
                    serviceFolder.Commit();
                }
                ViewBag.score = folder.testResult;
                ViewBag.type  = folder.typeTest;



                return(RedirectToAction("Index", "Attachment"));
            }
            catch {
                error = "vous devez remplir tous les champs";
                return(RedirectToAction("passerTest", "Test"));
            }
        }
        public ActionResult Create(BigViewModel bigViewModel, HttpPostedFileBase file, int idOffer)
        {
            List <String> spec = (new List <String> {
                "Software Engineering", "Graphic Designing", "Front end Developer", "IT Specialist"
            });

            ViewBag.list = spec;

            JobRequest job = new JobRequest();

            job.speciality = bigViewModel.jobRequestModel.speciality;
            //job.dateApply = bigViewModel.jobRequestModel.dateApply;
            job.dateApply = DateTime.Now;

            job.state   = "Pending";
            job.userId  = User.Identity.GetUserId <int>();
            job.offerId = idOffer;

            JobRequest jobRequestTest = serviceJob.getJobRequest(User.Identity.GetUserId <int>());

            if (jobRequestTest != null)
            {
                ViewBag.Message = "Vous avez deja inscrit";
                return(RedirectToAction("Details", "Offer", new { id = idOffer }));
            }

            else
            {
                serviceJob.Add(job);
                serviceJob.Commit();

                JobRequest getJob = serviceJob.getJobRequest(job.userId, 1);

                Folder     folder     = new Folder();
                Attachment attachment = new Attachment();
                folder.state        = "New Job Request";
                folder.jobRequestId = getJob.jobRequestId;
                folder.etape        = 0;

                serviceFolder.Add(folder);
                serviceFolder.Commit();

                // Folder getFolder = serviceFolder.getFolder(getJob);

                attachment.folderId       = folder.folderId;
                attachment.typeAttachment = "CV";
                attachment.proved         = "Pending";

                if (file == null)
                {
                    ModelState.AddModelError(bigViewModel.attachmentModel.lienAttachment, "Please Select CV");
                    return(View());
                }
                if (!(file.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document”" || file.ContentType == "application/pdf"))
                {
                    ModelState.AddModelError(bigViewModel.attachmentModel.lienAttachment, "Only .docs and .pdf file  allowed");
                    return(View());
                }

                if (ModelState.IsValid)
                {
                    try {
                        String fileName = Guid.NewGuid() + Path.GetExtension(file.FileName);
                        file.SaveAs(Path.Combine(Server.MapPath("~/UploadAttachment"), fileName));
                        attachment.lienAttachment = fileName;
                        serviceAttachment.Add(attachment);
                        serviceAttachment.Commit();
                        ViewBag.Message = "Successufuly Done";
                    } catch { ViewBag.Message = "Error Please try  again !!"; }
                }



                return(RedirectToAction("Index", "Folder"));
            }
        }