public IHttpActionResult PutPostuler(int id, Postuler postuler) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != postuler.id_post) { return(BadRequest()); } db.Entry(postuler).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!PostulerExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> confirmContratCandidat(decimal id) { Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == id); if (postuler == null) { return(HttpNotFound()); } postuler.signatures = "2"; postuler.situationTravail = "1"; postuler.dateSignatures = DateTime.Now; db.Entry(postuler).State = EntityState.Modified; var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", "Validation engagement de travail "); map.Add("@ViewBag.login", ""); map.Add("@ViewBag.content", "Le candidat " + postuler.Inscrire.login + " à lus et confirmer la signature de son engagement de travail pour le poste de " + postuler.Job.titre + ".veuillez suivre la candidature de ce candidat sur NioVarJobs"); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); await mail.Send(Constante.mailCompagny, "Contrat de travail signé et valider", body); db.SaveChanges(); return(RedirectToAction("MesCandidatures")); }
public ActionResult contratClient(decimal idPostuler) { if (Session["id"] != null) { decimal idCurrent = (decimal)Session["id"]; Inscrire inscritCurrent = db.Inscrire.FirstOrDefault(p => p.id == idCurrent); if (inscritCurrent == null) { return(HttpNotFound()); } ViewBag.inscritCurrent = inscritCurrent; Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == idPostuler); if (postuler == null) { return(HttpNotFound()); } Session.Add("postuler", postuler); return(View(postuler)); } else { return(HttpNotFound()); } return(View()); }
public IHttpActionResult PostPostuler(Postuler postuler) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Postuler.Add(postuler); try { db.SaveChanges(); } catch (DbUpdateException) { if (PostulerExists(postuler.id_post)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = postuler.id_post }, postuler)); }
public async Task <ActionResult> changeStatutSignatures(decimal id, string val, int remuneration) { Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == id); if (postuler == null) { return(HttpNotFound()); } postuler.signatures = val; postuler.remuneration = remuneration; db.Entry(postuler).State = EntityState.Modified; var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", postuler.Inscrire.login + " Nouvelle opportunité pour vous "); map.Add("@ViewBag.login", ""); map.Add("@ViewBag.content", "Votre candidature au poste de " + postuler.Job.titre + " à été accepté vous êtes convié à signer votre contrat recus via le dashbaord sur NioVarJobs"); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); await mail.Send(postuler.Inscrire.email, "Candidature accepté", body); db.SaveChanges(); return(RedirectToAction("listPostulantAdmin", new { id = postuler.Job_id })); }
public ActionResult DetailsOffreHome(decimal id) { if (id == null) { return(HttpNotFound()); } Postuler postuler = db.Postuler.Where(p => p.Job.archived == 1 && p.Inscrire.type == "client" && p.Job.status == 1 && p.Job_id == id).FirstOrDefault(); List <Postuler> listSimilaire = db.Postuler.Where(p => p.Job.archived == 1 && p.Inscrire.type == "client" && p.Job.status == 1 && p.Job.Cat_id == postuler.Job.Cat_id && p.approbation.Equals("1") && DateTime.Compare((DateTime)p.Job.dateFinOffre, DateTime.Now) > 0).OrderByDescending(p => p.Job.created).ToList(); listSimilaire.Remove(postuler); if (listSimilaire.Count <= 0) { ViewBag.listSimilaire = null; } else { ViewBag.listSimilaire = listSimilaire.Take(4); } List <DiplomeJob> listDiplomeJob = db.DiplomeJob.Where(p => p.archived == 1 && p.Job_id == postuler.Job_id).ToList(); ViewBag.listDiplomeJob = listDiplomeJob; List <AvantageSociauxJob> listAvantageSociauxJob = db.AvantageSociauxJob.Where(p => p.archived == 1 && p.Job_id == postuler.Job_id).ToList(); ViewBag.listAvantageSociauxJob = listAvantageSociauxJob; return(View(postuler)); }
public ActionResult contratTravailCandidat(decimal id, decimal idIns, decimal idJob) { Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == id); if (postuler == null) { return(HttpNotFound()); } return(View(postuler)); }
public JsonResult postuler(decimal id, int companyId) { if (_me == null) { return(Json(new { result_code = -1000, message = "Session expired" }, JsonRequestBehavior.AllowGet)); } if (_me.type.Equals("client") || _me.status == 0) { return(Json(new { result_code = -10, message = "Your are not Allowed" }, JsonRequestBehavior.AllowGet)); } Inscrire company = db.Inscrire.Find(companyId); if (company == null) { return(Json(new { result_code = -1, message = "Company not found" }, JsonRequestBehavior.AllowGet)); } Job job = db.Job.FirstOrDefault(p => p.id == id); if (job == null) { return(Json(new { result_code = -1, message = "job not found" }, JsonRequestBehavior.AllowGet)); } Postuler result = db.Postuler.Where(p => p.Ins_id == _me.id && p.Job_id == id && p.Inscrire.type.Equals("candidat") && p.archived == 1 && p.compagnyId == companyId).FirstOrDefault(); if (result != null) { return(Json(new { result_code = -1, message = "You are already apply this job" }, JsonRequestBehavior.AllowGet)); } Postuler postuler = new Postuler(); postuler.Job_id = id; postuler.Job = job; postuler.Ins_id = _me.id; postuler.compagnyId = companyId; postuler.created = DateTime.Now; postuler.archived = 1; postuler.status = 1; postuler.etat = "0"; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.situationTravail = "0"; db.Postuler.Add(postuler); db.SaveChanges(); return(Json(new { result_code = 1, data = getJson(postuler) }, JsonRequestBehavior.AllowGet)); }
public ActionResult changeStatusPoste(decimal id, String val) { Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == id); if (postuler == null) { return(HttpNotFound()); } postuler.situationTravail = val; db.Entry(postuler).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("ManageEmploye")); }
public IHttpActionResult DeletePostuler(int id) { Postuler postuler = db.Postuler.Find(id); if (postuler == null) { return(NotFound()); } db.Postuler.Remove(postuler); db.SaveChanges(); return(Ok(postuler)); }
protected Dictionary <string, Object> getJson(Postuler item) { var json = new Dictionary <string, Object>(); if (item == null) { return(null); } json.Add("id", item.id); json.Add("typeJob", item.typeJob); json.Add("Ins_id", item.Ins_id); json.Add("Job_id", item.Job_id); json.Add("libelle", item.libelle); json.Add("datePostule", item.datePostule.HasValue ? item.datePostule.Value.ToString("dd/MM/yyyy HH:mm") : null); json.Add("heurePostule", item.heurePostule); json.Add("remuneration", item.remuneration); json.Add("remuneration2", item.Job.immediat.Equals("true") ? (Convert.ToDouble(item.Job.remunerationN) / 2) : (item.Job.remuneration / 2)); json.Add("etatAdmin", item.etatAdmin); json.Add("etat", item.etat); json.Add("status", item.status); json.Add("nbreApply", item.nbreApply); json.Add("created", item.created.HasValue ? item.created.Value.ToString("dd/MM/yyyy HH:mm") : null); //("dddd, dd MMMM yyyy") json.Add("created_format", item.created.HasValue ? Utils.dateFullMonth(item.created.Value) : null); json.Add("etatClient", item.etatClient); json.Add("etatCandidat", item.etatCandidat); json.Add("approbation", item.approbation); json.Add("signatures", item.signatures); json.Add("situation_travail", item.situationTravail); json.Add("date_embauche", item.dateEmbauche.HasValue ? item.dateEmbauche.Value.ToString("dd/MM/yyyy HH:mm") : null); json.Add("date_embauche_format", item.dateEmbauche.HasValue ? Utils.dateFullMonth(item.dateEmbauche.Value) : null); json.Add("date_signatures", item.dateSignatures.HasValue ? item.dateSignatures.Value.ToString("dd/MM/yyyy HH:mm") : null); json.Add("date_signatures_format", item.dateSignatures.HasValue ? Utils.dateFullMonth(item.dateSignatures.Value) : null); json.Add("dateEntrevue", item.dateEntrevue.HasValue ? item.dateEntrevue.Value.ToString("dd/MM/yyyy HH:mm") : null); json.Add("dateEntrevue_format", item.dateEntrevue.HasValue ? Utils.dateFullMonth(item.dateEntrevue.Value) : null); json.Add("heure", item.heure); json.Add("responsableEntrevue", item.responsableEntrevue); json.Add("duree", item.duree); json.Add("outils", item.outils); json.Add("signatureClient", item.signatureClient); json.Add("dateSignClient", item.dateSignClient.HasValue ? item.dateSignClient.Value.ToString("dd/MM/yyyy HH:mm") : null); json.Add("inscrire", getJson(item.Inscrire)); json.Add("job", getJson(item.Job)); json.Add("image", MsMail.baseUrl + (item.Job.immediat.Equals("true") ? "Assets/images/logo2.png" : "Fichier/" + item.Inscrire.profil)); json.Add("companyId", item.compagnyId.HasValue ? item.compagnyId.Value : 0); json.Add("company", getJson(Utils.getCompany(db, item.compagnyId))); return(json); }
public ActionResult detailsOffreAdmin(decimal id) { if (id == null) { return(HttpNotFound()); } Postuler postuler = db.Postuler.Where(p => p.Job.archived == 1 && p.Inscrire.type == "client" && p.Job.status == 1 && p.Job_id == id).FirstOrDefault(); List <DiplomeJob> listDiplomeJob = db.DiplomeJob.Where(p => p.archived == 1 && p.Job_id == id).ToList(); ViewBag.listDiplomeJob = listDiplomeJob; List <AvantageSociauxJob> listAvantageSociauxJob = db.AvantageSociauxJob.Where(p => p.archived == 1 && p.Job_id == id).ToList(); ViewBag.listAvantageSociauxJob = listAvantageSociauxJob; return(View(postuler)); }
public async Task <ActionResult> EditEtatCandidat(decimal id, decimal idJob, String status, int salFinal) { try { Postuler currentPostuler = db.Postuler.FirstOrDefault(p => p.id == id); if (currentPostuler == null) { ViewBag.Message = "Votre compte n'existe pas !"; TempData["myData"] = "0"; return(RedirectToAction("listPostulantAdmin", new { id = idJob })); } if (status.Equals("2")) { currentPostuler.remuneration = salFinal; Postuler currentEmployeur = db.Postuler.Where(p => p.Job_id == idJob && p.Inscrire.type.Equals("client") && p.archived == 1).FirstOrDefault(); var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", "Un candidat est intérésser par votre offre de " + currentEmployeur.Job.titre); map.Add("@ViewBag.login", ""); map.Add("@ViewBag.content", "Vous avez reçus une candidature pour le poste de :" + currentEmployeur.Job.titre + ".veuillez suivre la candidature de ce candidat sur NioVarJobs"); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); await mail.Send(currentEmployeur.Inscrire.email, "Candidat intérésser", body); } currentPostuler.etatCandidat = status; db.Entry(currentPostuler).State = EntityState.Modified; db.SaveChanges(); TempData["myData"] = "1"; TempData["message"] = "Status modifié avec succès"; return(RedirectToAction("listPostulantAdmin", new { id = idJob })); } catch (Exception) { TempData["myData"] = "0"; return(RedirectToAction("listPostulantAdmin", new { id = idJob })); } }
public JsonResult setReader(decimal id) { if (_me == null) { return(Json(new { result_code = -1000, message = "Session expired" }, JsonRequestBehavior.AllowGet)); } Postuler postuler = db.Postuler.Where(p => p.id == id).FirstOrDefault(); if (postuler == null) { return(Json(new { result_code = -1, message = "data not found" }, JsonRequestBehavior.AllowGet)); } postuler.etat = "1"; ViewBag.immediat = postuler.Job.immediat; db.Entry(postuler).State = EntityState.Modified; db.SaveChanges(); return(Json(new { result_code = 1 }, JsonRequestBehavior.AllowGet)); }
public JsonResult confirmContratCandidat(decimal id) { if (_me == null) { return(Json(new { result_code = -1000, message = "Session expired" }, JsonRequestBehavior.AllowGet)); } Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == id); if (postuler == null) { return(Json(new { result_code = -1, message = "item not found" }, JsonRequestBehavior.AllowGet)); } postuler.signatures = "2"; postuler.situationTravail = "1"; postuler.dateSignatures = DateTime.Now; db.Entry(postuler).State = EntityState.Modified; db.SaveChanges(); return(Json(new { result_code = 1, data = getJson(postuler) }, JsonRequestBehavior.AllowGet)); }
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 async Task <JsonResult> PayContratClient(String stripeToken, Decimal idPostuler) { if (_me == null) { return(Json(new { result_code = -1000, message = "Session expired" }, JsonRequestBehavior.AllowGet)); } if (_me.type != "client") { return(Json(new { result_code = -10, message = "Not autorized for this action" }, JsonRequestBehavior.AllowGet)); } Postuler postuler = db.Postuler.FirstOrDefault(x => x.id == idPostuler); if (postuler == null || String.IsNullOrEmpty(stripeToken)) { return(Json(new { result_code = -1, message = "Data not found" }, JsonRequestBehavior.AllowGet)); } StripeConfiguration.SetApiKey(STRIPE_API_KEY); double amount = postuler.Job.remuneration.Value * 25 / 100; if (amount <= 0) { return(Json(new { result_code = -1, message = "Amount not valid" }, JsonRequestBehavior.AllowGet)); } var stripeOptions = new ChargeCreateOptions { Amount = (long)amount, // 1 dollar is equal to 100 cent. Currency = "USD", Description = "Charge for payment of 25% of" + postuler.libelle, Source = stripeToken, }; var service = new ChargeService(); postuler.etatClient = "2"; postuler.signatureClient = 1; postuler.dateSignClient = DateTime.Now; db.Entry(postuler).State = EntityState.Modified; Paiement paiement = new Paiement(); paiement.archived = 1; paiement.avance = amount; paiement.created = DateTime.Now; paiement.etat = 0; //TODO mettre le bon etat paiement.status = 0; //TODO mettre le bon status je suppose o veut dire non achevé paiement.Ins_id = postuler.Ins_id; paiement.Job_id = postuler.Job_id; paiement.libelle = "Paiement de 25% de l'offre"; paiement.montant = postuler.Job.remuneration.Value; paiement.Pos_id = postuler.id; paiement.userId = Convert.ToInt32(_me.id); paiement.reste = postuler.Job.remuneration - amount; db.Paiement.Add(paiement); try { Charge charge = service.Create(stripeOptions); var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", "Paiement de 25% du salaire via skype" + postuler.libelle); map.Add("@ViewBag.login", _me.login); map.Add("@ViewBag.content", "Votre paiement a bien été pris en compte. Le montant à été prélever de votre compte avec succès. Reste à payer : 5 $. Bénéficiez du meilleur de nos service."); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); db.SaveChanges(); //TODO retraviller le mail avec du HTML await mail.Send(_me.email, "Paiement", body); //TODO rediriger a la liste des candidatures return(Json(new { result_code = 1, postuler = getJson(postuler), payment = getJson(paiement) }, JsonRequestBehavior.AllowGet)); } catch (StripeException e) { return(Json(new { result_code = -1, message = "An exception occured" }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> contratClient(String stripeToken) { Postuler currentPostuler = (Postuler)Session["postuler"]; if (currentPostuler == null || _me == null || _me.type != "client") { TempData["result_code"] = -1; TempData["message"] = "Temps fourni pour le payment est expiré veuillez réessayer."; TempData.Keep(); //TODO rediriger a la liste des candidatures return(RedirectToAction("Index", "Home")); } if (String.IsNullOrEmpty(stripeToken)) { return(HttpNotFound()); } StripeConfiguration.SetApiKey(STRIPE_API_KEY); var stripeOptions = new ChargeCreateOptions { Amount = (long)Math.Ceiling(currentPostuler.Job.remuneration.Value) * 25 / 100, // 1 dollar is equal to 100 cent. Currency = "USD", Description = "Charge for payment of 25% of" + currentPostuler.libelle, Source = stripeToken, //Customer = customer.Id }; var service = new ChargeService(); if (Session["id"] == null) { return(HttpNotFound()); } int idUserSession = Convert.ToInt32(Session["id"]); Postuler postuler = db.Postuler.FirstOrDefault(p => p.id == currentPostuler.id); if (postuler == null) { return(HttpNotFound()); } postuler.etatClient = "2"; postuler.signatureClient = 1; postuler.dateSignClient = DateTime.Now; db.Entry(postuler).State = EntityState.Modified; double amount = postuler.Job.remuneration.Value * 25 / 100; Paiement paiement = new Paiement(); paiement.archived = 1; paiement.avance = amount; paiement.created = DateTime.Now; paiement.etat = 0; //TODO mettre le bon etat paiement.Ins_id = postuler.Ins_id; paiement.Job_id = postuler.Job_id; paiement.libelle = "Paiement de 25% de l'offre "; paiement.montant = postuler.Job.remuneration.Value; paiement.Pos_id = postuler.id; paiement.userId = idUserSession; paiement.reste = postuler.Job.remuneration - amount; paiement.status = 0; //TODO mettre le bon status je suppose o veut dire non achevé db.Paiement.Add(paiement); try { Charge charge = service.Create(stripeOptions); var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", "Paiement de 25% du salaire via stripe " + currentPostuler.libelle); map.Add("@ViewBag.login", _me.login); map.Add("@ViewBag.content", "Votre paiement a bien été pris en compte. Le montant à été prélever de votre compte avec succès. Reste à payer :" + paiement.reste + ". Bénéficiez du meilleur de nos service."); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); db.SaveChanges(); List <string> mylistmail = new List <string>(new string[] { _me.email, Constante.mailCompagny }); //TODO retraviller le mail avec du HTML await mail.Send(mylistmail, "Paiement frais location candidat", body); //TODO rediriger a la liste des candidatures return(RedirectToAction("ListPostulant", new { id = postuler.Job_id })); } catch (StripeException e) { } ViewBag.inscritCurrent = _me; return(View(currentPostuler)); }
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)); } }
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 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 async Task <ActionResult> postuler(decimal id) { decimal idJob = id; if (Session.Count > 0 && Session["status"] != null) { if (Session["type"].Equals("client")) { String message = "Vous ne pouvez pas postuler à cette offre. Seul les travailleurs intéressés ou ayant un compte candidat peuvent postuler."; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } else { decimal status = Convert.ToDecimal(Session["status"]); if (status == 0) { String message = "Vous ne pouvez pas pour le moment postulé à une offre. Vérifier que vos informations sont bien renseignez dans votre profil et attendez l'activation de votre profil par les administrateurs NiovarJobs. Sinon contactez nous "; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } decimal idPostulant = Convert.ToDecimal(Session["id"]); Postuler result = db.Postuler.Where(p => p.Ins_id == idPostulant && p.Job_id == idJob && p.Inscrire.type.Equals("candidat") && p.archived == 1).FirstOrDefault(); if (result != null) { String message = "Vous ne pouvez pas postuler a un même offre d'emploi deux fois "; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } else { Postuler currentEmployeur = db.Postuler.Where(p => p.Job_id == idJob && p.Inscrire.type.Equals("client") && p.archived == 1).FirstOrDefault(); if (currentEmployeur == null) { String message = "La compagnie propriétaire de cette publication n'existe pas "; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } Postuler postuler = new Postuler(); postuler.Job_id = idJob; postuler.Ins_id = idPostulant; postuler.created = DateTime.Now; postuler.archived = 1; postuler.status = 1; postuler.etat = "0"; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.situationTravail = "0"; db.Postuler.Add(postuler); TempData["myData"] = "1"; TempData["message"] = "Votre candidature a été envoyer avec succès"; string emailTo = currentEmployeur.Inscrire.email; if (currentEmployeur.Job.immediat.Equals("true")) { emailTo = Constante.mailCompagny; } var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", "Un candidat est intérésser par votre offre de " + currentEmployeur.Job.titre); map.Add("@ViewBag.login", ""); map.Add("@ViewBag.content", "Le candidat " + Session["login"] + " à deposer sa candidature pour le poste de :" + currentEmployeur.Job.titre + ".veuillez suivre la candidature de ce candidat sur NioVarJobs"); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); await mail.Send(emailTo, "Candidat intérésser", body); db.SaveChanges(); } return(RedirectToAction("MesCandidatures", "Offre")); } } else { return(RedirectToAction("Login", "Inscrires")); } }
public async Task <ActionResult> postulerDirectement(MailsModel mailsModel) { if (mailsModel.To == null) { String message = "Veuillez renseignez son l'email"; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } List <string> listFichier = new List <string>(); if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { try { var filename = Path.GetFileName(file.FileName); //verification de l'extention du fichiers var supportedTypes = new[] { ".png", ".jpg", ".jpeg", ".gif", ".pdf", ".docx" }; var extention = Path.GetExtension(filename); if (!supportedTypes.Contains(extention)) { String message = "L'extention du fichier n'est pas valide !"; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } //end verification var formattedFilename = string.Format("{0}-{1}{2}" , Path.GetFileNameWithoutExtension(filename) , Guid.NewGuid().ToString("N") , Path.GetExtension(filename)); string path = Path.Combine(Server.MapPath("~/Fichier"), Path.GetFileName(formattedFilename)); file.SaveAs(path); listFichier.Add(path); } catch (Exception ex) { String message = "erreur de l'upload du fichier"; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } } } try { decimal idPostulant = Convert.ToDecimal(Session["id"]); Postuler postuler = new Postuler(); postuler.Job_id = mailsModel.idJob; postuler.Ins_id = idPostulant; postuler.created = DateTime.Now; postuler.archived = 1; postuler.status = 1; postuler.etat = "0"; postuler.etatAdmin = "0"; postuler.etatClient = "0"; postuler.etatCandidat = "0"; postuler.signatures = "0"; postuler.signatureClient = 0; postuler.situationTravail = "0"; db.Postuler.Add(postuler); var map = new Dictionary <String, String>(); map.Add("@ViewBag.titre", "Nouvelle candidature"); map.Add("@ViewBag.login", ""); map.Add("@ViewBag.content", mailsModel.message); string body = MsMail.BuldBodyTemplate("~/EmailTemplate/CustomEmail.cshtml", map); MsMail mail = new MsMail(); await mail.Send(mailsModel.To, mailsModel.subject, body, null, null, listFichier); db.SaveChanges(); db.SaveChanges(); String message = "candidature envoyé avec succès"; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } catch (Exception e) { String message = "echec veuillez reessayer"; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } }
public ActionResult CvResumePostulant(decimal id, decimal id_job) { if (id == null) { String message = "Une erreur c'est produit durant l'opération veuillez reessayer !"; return(RedirectToAction("ErrorPage", "Home", new { sms = message })); } Postuler postuler = db.Postuler.Where(p => p.Ins_id == id && p.Job_id == id_job).FirstOrDefault(); postuler.etat = "1"; ViewBag.etatClient = postuler.etatClient; ViewBag.immediat = postuler.Job.immediat; db.Entry(postuler).State = EntityState.Modified; db.SaveChanges(); Information information = db.Information.FirstOrDefault(p => p.Ins_id == id); Inscrire inscrire = db.Inscrire.FirstOrDefault(p => p.id == id); if (information == null) { information = new Information(); } List <Education> education = db.Education.Where(p => p.Ins_id == id).ToList(); if (education.Count > 0) { ViewBag.listEducation = education; } else { ViewBag.listEducation = null; } List <Experience> experiences = db.Experience.Where(p => p.Ins_id == id).ToList(); if (experiences.Count > 0) { ViewBag.listExperience = experiences; } else { ViewBag.listExperience = null; } List <Autre> autres = db.Autre.Where(p => p.Ins_id == id).ToList(); if (autres.Count > 0) { ViewBag.listAutre = autres; } else { ViewBag.listAutre = null; } CvListObject model = new CvListObject(); model.information = information; model.education = new Education(); model.experience = new Experience(); model.autre = new Autre(); model.inscrire = inscrire; return(View(model)); }