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 changeApprobation(decimal id, String remunarationFinal, int masqueEmpla, string eqtEmp, string json) { try { var currentPostuler = db.Postuler.FirstOrDefault(p => p.id == id); if (currentPostuler == null) { TempData["myData"] = "0"; return(RedirectToAction("ManageOffreAdmin")); } var currentJob = db.Job.Where(p => p.id == currentPostuler.Job_id).FirstOrDefault(); if (currentJob == null) { TempData["myData"] = "0"; return(RedirectToAction("ManageOffreAdmin")); } if (Convert.ToDouble(remunarationFinal) > currentPostuler.Job.remuneration) { TempData["myData"] = "1"; TempData["message"] = "Echec ! Le montant saisie doit être inférieur au salaire proposé "; return(RedirectToAction("ManageOffreAdmin")); } if (currentPostuler.approbation.Equals("1")) { currentPostuler.approbation = "0"; TempData["message"] = "Approbation annuler avec succès"; } else { string[] arr = json.Split(','); if (arr.Length > 0) { for (int i = 0; i < arr.Length; i++) { AvantageSociauxJob avantageSociauxJob = new AvantageSociauxJob(); avantageSociauxJob.archived = 1; avantageSociauxJob.created = DateTime.Now; avantageSociauxJob.Job_id = currentJob.id; avantageSociauxJob.Ava_id = Convert.ToDecimal(arr[i]); db.AvantageSociauxJob.Add(avantageSociauxJob); } } currentPostuler.Job.remunerationN = Convert.ToDouble(remunarationFinal); currentPostuler.approbation = "1"; currentJob.equipeEmploi = eqtEmp; currentJob.masquerEmplacement = masqueEmpla; TempData["message"] = "Approbation confirmé avec succès"; db.Entry(currentPostuler).State = EntityState.Modified; db.Entry(currentJob).State = EntityState.Modified; db.SaveChanges(); } TempData["myData"] = "1"; return(RedirectToAction("ManageOffreAdmin")); } catch (Exception) { TempData["myData"] = "0"; return(RedirectToAction("ManageOffreAdmin")); } }
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 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)); } }