// GET: Offer/Details/5 public ActionResult Details(int id) { List <String> spec = (new List <String> { "Software Engineering", "Graphic Designing", "Front end Developer", "IT Specialist" }); ViewBag.list = spec; OfferJobs offer = serviceOffer.GetById(id); BigViewModel bigViewModel = new BigViewModel(); OfferViewModel offerViewModel = new OfferViewModel(); offerViewModel.offerId = id; offerViewModel.JobType = offer.JobType; offerViewModel.JobDescription = offer.JobDescription; offerViewModel.JobExperience = offer.JobExperience; offerViewModel.JobRequirements = offer.JobRequirements; offerViewModel.offerId = offer.offerId; //OfferViewModel.userId = item.userId; offerViewModel.PostedOn = offer.PostedOn; offerViewModel.LastDay = offer.LastDay; offerViewModel.ExpectedSalary = offer.ExpectedSalary; bigViewModel.offerViewModel = offerViewModel; JobRequest jobRequestTest = serviceJob.getJobRequest(User.Identity.GetUserId <int>()); if (jobRequestTest != null) { ViewBag.Message = "Vous avez deja inscrit"; } return(View(bigViewModel)); }
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")); } }