public ActionResult PostOffre(Job job) { if (job.immediat.Equals("false") && needAbonnement()) { return(RedirectToAction("Abonnement", "Inscrires")); } if (ModelState.IsValid) { try { string daysWork = ""; for (int i = 0; i < job.workDay.Length; i++) { daysWork += job.workDay[i].ToString() + ","; } daysWork = daysWork.TrimEnd(','); job.jourTravail = daysWork; job.status = 1; job.archived = 1; job.etat = "1"; job.created = DateTime.Now; db.Job.Add(job); db.SaveChanges(); for (int i = 0; i < job.listDip.Length; i++) { DiplomeJob diplomeJob = new DiplomeJob(); diplomeJob.archived = 1; diplomeJob.created = DateTime.Now; diplomeJob.Job_id = job.id; diplomeJob.Dip_id = Convert.ToDecimal(job.listDip[i]); db.DiplomeJob.Add(diplomeJob); } if (job.listAvantage.Length > 0) { for (int i = 0; i < job.listAvantage.Length; i++) { AvantageSociauxJob avantageSociauxJob = new AvantageSociauxJob(); avantageSociauxJob.archived = 1; avantageSociauxJob.created = DateTime.Now; avantageSociauxJob.Job_id = job.id; avantageSociauxJob.Ava_id = Convert.ToDecimal(job.listAvantage[i]); db.AvantageSociauxJob.Add(avantageSociauxJob); } } db.SaveChanges(); Postuler postuler = new Postuler(); postuler.Job_id = job.id; postuler.Ins_id = Convert.ToDecimal(Session["id"]); postuler.created = DateTime.Now; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.etat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.approbation = "0"; postuler.situationTravail = "0"; if (job.immediat.Equals("true")) { postuler.approbation = "0"; } else { postuler.approbation = "1"; if (lastAsbonnement != null) { InsAbonne currentInsAbonnement = db.InsAbonne.Where(p => p.id == lastAsbonnement.id).First(); currentInsAbonnement.etat -= 1; currentInsAbonnement.nbrePost -= 1; db.Entry(currentInsAbonnement).State = EntityState.Modified; db.SaveChanges(); } else { return(RedirectToAction("Abonnement", "Inscrires")); } } postuler.situationTravail = "0"; postuler.archived = 1; db.Postuler.Add(postuler); db.SaveChanges(); TempData["result_code"] = 1; TempData["message"] = "Offre d'emploi publié avec succès."; TempData.Keep(); return(RedirectToAction("ManagerOffre")); } catch (Exception e) { ViewBag.Error = e.Message.ToString(); TempData["result_code"] = -1; TempData["message"] = "Données non valide. veuillez renseignez tous les champs obligatoire (*)"; TempData.Keep(); return(View(job)); } } TempData["result_code"] = -1; TempData["message"] = "Données non valide. veuillez renseignez tous les champs"; TempData.Keep(); return(View(job)); }
public ActionResult publierOffreAdmin(Job job) { Inscrire currentUser = db.Inscrire.Where(x => x.email == job.courriel || x.nom == job.nomEntreprise && x.archived == 1).FirstOrDefault(); if (ModelState.IsValid) { try { string daysWork = ""; for (int i = 0; i < job.workDay.Length; i++) { daysWork += job.workDay[i].ToString() + ","; } daysWork = daysWork.TrimEnd(','); job.jourTravail = daysWork; job.status = 1; job.archived = 1; job.etat = "1"; job.created = DateTime.Now; job.immediat = "direct"; db.Job.Add(job); db.SaveChanges(); for (int i = 0; i < job.listDip.Length; i++) { DiplomeJob diplomeJob = new DiplomeJob(); diplomeJob.archived = 1; diplomeJob.created = DateTime.Now; diplomeJob.Job_id = job.id; diplomeJob.Dip_id = Convert.ToDecimal(job.listDip[i]); db.DiplomeJob.Add(diplomeJob); } if (job.listAvantage.Length > 0) { for (int i = 0; i < job.listAvantage.Length; i++) { AvantageSociauxJob avantageSociauxJob = new AvantageSociauxJob(); avantageSociauxJob.archived = 1; avantageSociauxJob.created = DateTime.Now; avantageSociauxJob.Job_id = job.id; avantageSociauxJob.Ava_id = Convert.ToDecimal(job.listAvantage[i]); db.AvantageSociauxJob.Add(avantageSociauxJob); } } db.SaveChanges(); decimal id; if (currentUser != null) { id = currentUser.id; } else { Inscrire inscrire = new Inscrire(); inscrire.type = Constante.typeclient; inscrire.nom = job.nomEntreprise; inscrire.login = job.nomEntreprise; inscrire.adresse = job.adresse; inscrire.phone = job.telephone; inscrire.email = job.courriel; inscrire.emailProf = job.courriel; inscrire.password = Constante.defaultPwd; inscrire.cpassword = inscrire.password; inscrire.etat = 1; inscrire.status = 1; inscrire.archived = 1; db.Inscrire.Add(inscrire); db.SaveChanges(); id = inscrire.id; } Postuler postuler = new Postuler(); postuler.Job_id = job.id; postuler.Ins_id = id; postuler.created = DateTime.Now; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.etat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.approbation = "1"; postuler.situationTravail = "0"; postuler.archived = 1; db.Postuler.Add(postuler); db.SaveChanges(); TempData["result_code"] = 1; TempData["message"] = "Offre d'emploi publié avec succès."; TempData.Keep(); return(RedirectToAction("offreNiovarJobs", "Admin")); } catch (Exception e) { ViewBag.Error = e.Message.ToString(); TempData["result_code"] = -1; TempData["message"] = "Données non valide. veuillez renseignez tous les champs obligatoire (*)"; TempData.Keep(); return(View(job)); } } TempData["result_code"] = -1; TempData["message"] = "Données non valide. veuillez renseignez tous les champs"; TempData.Keep(); return(View(job)); }
public ActionResult TrouverEmployer(Job job) { if (ModelState.IsValid) { try { string daysWork = ""; for (int i = 0; i < job.workDay.Length; i++) { daysWork += job.workDay[i].ToString() + ","; } daysWork = daysWork.TrimEnd(','); job.jourTravail = daysWork; job.status = 1; job.archived = 1; job.etat = "1"; job.created = DateTime.Now; job.dateFinOffre = job.dateFin; db.Job.Add(job); db.SaveChanges(); if (job.listDip.Length > 0) { for (int i = 0; i < job.listDip.Length; i++) { DiplomeJob diplomeJob = new DiplomeJob(); diplomeJob.archived = 1; diplomeJob.created = DateTime.Now; diplomeJob.Job_id = job.id; diplomeJob.Dip_id = Convert.ToDecimal(job.listDip[i]); db.DiplomeJob.Add(diplomeJob); } } db.SaveChanges(); Postuler postuler = new Postuler(); postuler.Job_id = job.id; postuler.Ins_id = Convert.ToDecimal(Session["id"]); postuler.created = DateTime.Now; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.etat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.approbation = "0"; postuler.situationTravail = "0"; postuler.approbation = "0"; postuler.situationTravail = "0"; postuler.archived = 1; db.Postuler.Add(postuler); db.SaveChanges(); TempData["result_code"] = 1; TempData["message"] = "Votre Demande a été envoyé succès."; TempData.Keep(); return(RedirectToAction("ManageMainOeuvre")); } catch (Exception e) { ViewBag.Error = e.Message.ToString(); TempData["result_code"] = -1; TempData["message"] = "Données non valide. veuillez renseignez tous les champs obligatoire (*)"; TempData.Keep(); return(View(job)); } } TempData["result_code"] = -1; TempData["message"] = "Données non valide. veuillez renseignez tous les champs"; TempData.Keep(); return(View(job)); }
public JsonResult PostOffre(Job job) { if (_me == null) { return(Json(new { result_code = -1000, message = "Session expired" }, JsonRequestBehavior.AllowGet)); } if (job.immediat.Equals("false") && needAbonnement()) { return(Json(new { result_code = -10, message = "You need abonnement" }, JsonRequestBehavior.AllowGet)); } try { string daysWork = ""; for (int i = 0; i < job.workDay.Length; i++) { daysWork += job.workDay[i].ToString() + ","; } daysWork = daysWork.TrimEnd(','); job.jourTravail = daysWork; job.status = 1; job.archived = 1; job.etat = "1"; job.created = DateTime.Now; db.Job.Add(job); db.SaveChanges(); var dipArray = job.listDipStr.Split(','); for (int i = 0; i < dipArray.Length; i++) { DiplomeJob diplomeJob = new DiplomeJob(); diplomeJob.archived = 1; diplomeJob.created = DateTime.Now; diplomeJob.Job_id = job.id; var dipId = Decimal.Parse(dipArray[i]); diplomeJob.Dip_id = dipId; db.DiplomeJob.Add(diplomeJob); } var avanArray = job.listAvantageStr.Split(','); for (int i = 0; i < avanArray.Length; i++) { AvantageSociauxJob avantageSociauxJob = new AvantageSociauxJob(); avantageSociauxJob.archived = 1; avantageSociauxJob.created = DateTime.Now; avantageSociauxJob.Job_id = job.id; avantageSociauxJob.Ava_id = Decimal.Parse(avanArray[i]); db.AvantageSociauxJob.Add(avantageSociauxJob); } db.SaveChanges(); Postuler postuler = new Postuler(); postuler.Job_id = job.id; postuler.Ins_id = _me.id; postuler.created = DateTime.Now; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.etat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.approbation = "0"; postuler.situationTravail = "0"; if (job.immediat.Equals("true")) { postuler.approbation = "0"; } else { postuler.approbation = "1"; if (lastAsbonnement != null) { InsAbonne currentInsAbonnement = db.InsAbonne.Where(p => p.id == lastAsbonnement.id).First(); currentInsAbonnement.etat -= 1; currentInsAbonnement.nbrePost -= 1; db.Entry(currentInsAbonnement).State = EntityState.Modified; db.SaveChanges(); } else { return(Json(new { result_code = -1, message = "Abonnement not found" }, JsonRequestBehavior.AllowGet)); } } postuler.situationTravail = "0"; postuler.archived = 1; db.Postuler.Add(postuler); db.SaveChanges(); return(Json(new { result_code = 1, data = getJson(postuler) }, JsonRequestBehavior.AllowGet)); } catch (Exception e) { throw; return(Json(new { result_code = -2, message = "An error occured" }, JsonRequestBehavior.AllowGet)); } }