public CandidacySummary(Candidacy candidacy) { Id = candidacy.Id; Name = candidacy.Name; Description = candidacy.Description; Photo = candidacy.PhotoPath; }
public static async Task <bool> SendEmail(Candidacy candidacy) { bool result = false; try { MailMessage message = new MailMessage(candidacy.Contact.Email, Recipient); message.Subject = "Nouvelle candidature"; message.IsBodyHtml = true; message.Body = GetBody().Replace("[CANDIDACYNAME]", String.Concat(candidacy.Contact.LastName, " ", candidacy.Contact.FirstName)); candidacy.Avatar.Seek(0, SeekOrigin.Begin); candidacy.CV.Seek(0, SeekOrigin.Begin); message.Attachments.Add(new Attachment(candidacy.CV, "CV.pdf")); message.Attachments.Add(new Attachment(candidacy.Avatar, "avatar.png")); //Définir un SMTP par défaut afin de pouvoir envoyer les emails SmtpClient smtp = new SmtpClient(); smtp.Port = 587; smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential("*****@*****.**", "toan14arthsoft"); smtp.DeliveryMethod = SmtpDeliveryMethod.Network; await smtp.SendMailAsync(message); } catch (Exception e) { Console.WriteLine(e.ToString()); } return(result); }
public void AddCandidate(string userId, int jobOfferId, string headhunterId) { var user = this.users.GetById(headhunterId); if (user.HeadhunterProfile == null) { user.HeadhunterProfile = new HeadhunterProfile { UserId = headhunterId }; this.users.Update(user); this.users.SaveChanges(); } var candidacy = new Candidacy { DeveloperProfileId = userId, HeadhunterProfileId = headhunterId, JobOfferId = jobOfferId, IsApproved = false }; this.candidacies.Add(candidacy); this.candidacies.Save(); var jobOffer = this.jobOffers.GetById(jobOfferId); jobOffer.HeadhunterProfileId = headhunterId; this.jobOffers.Update(jobOffer); this.jobOffers.Save(); }
public void Add_Normal_Conditionals() { var repo = new CandidacyRepository(); var user = new UserDetailsRepository().GetAll().FirstOrDefault(); var candidacy = new Candidacy("John", "empty description", "empty", user); repo.Add(candidacy); Assert.True(repo.GetAll().Last().Owner != null); }
public async Task <IActionResult> ChangeStatusFromManagedApplications(int adId, string candidateId, string status) { Candidacy cd = db.Candidacies.FirstOrDefault(a => a.AdvertisementId == adId && a.UserId.Equals(candidateId)); cd.Status = status; db.Candidacies.Update(cd); await db.SaveChangesAsync(); return(RedirectToAction("ManagedApplications")); }
public void Add_Description_Null() { var repo = new CandidacyRepository(); var user = new UserDetails(); Assert.Throws <ArgumentNullException>(() => { var candidacy = new Candidacy("John", null, "empty", user); repo.Add(candidacy); }); }
public async Task <IActionResult> Delete(int adId) { User currentUser = await signInManager.UserManager.GetUserAsync(this.User); Candidacy cd = db.Candidacies.FirstOrDefault(a => a.AdvertisementId == adId && a.UserId.Equals(currentUser.Id)); cd.IsDeleted = 1; db.Candidacies.Update(cd); await db.SaveChangesAsync(); return(RedirectToAction("AppliedJobs", "Profile")); }
public void Add_User_Null() { var repo = new CandidacyRepository(); UserDetails userDetails = null; Assert.Throws <ArgumentNullException>(() => { var candidacy = new Candidacy("John", "empty description", "empty", userDetails); repo.Add(candidacy); }); }
public void Delete_Normal_Conditions() { var repo = new CandidacyRepository(); var user = new UserDetails(); var userRepo = new UserDetailsRepository(); userRepo.Add(user); var candidacy = new Candidacy("John", "empty description", "empty", user); repo.Add(candidacy); repo.Delete(repo.GetAll().FirstOrDefault()); }
public void Edit_Normal_Conditions() { var repo = new CandidacyRepository(); var user = new UserDetails(); var userRepo = new UserDetailsRepository(); userRepo.Add(user); var candidacy = new Candidacy("John", "empty description", "empty", user); repo.Add(candidacy); var temp = repo.GetAll().FirstOrDefault(); temp.PhotoPath = "foo"; temp.Description = "bar"; repo.Edit(temp); }
public ActionResult Save(Candidacy candidacy) { if (!ModelState.IsValid) { var viewModel = new CandidacyViewModel { Candidacy = candidacy, Categories = _context.Categories.ToList() }; return(View("CandidacyList", viewModel)); } _context.Candidacys.Add(candidacy); _context.SaveChanges(); return(RedirectToAction("Index")); }
public void Edit_PhotoPath_Null() { var repo = new CandidacyRepository(); var user = new UserDetails(); var userRepo = new UserDetailsRepository(); userRepo.Add(user); var candidacy = new Candidacy("John", "empty description", "empty", user); repo.Add(candidacy); var temp = repo.GetAll().FirstOrDefault(); Assert.Throws <ArgumentNullException>(() => { temp.PhotoPath = null; temp.Description = "bar"; repo.Edit(temp); }); }
public async Task <IActionResult> Create(int adId) { User currentUser = await signInManager.UserManager.GetUserAsync(this.User); Candidacy cd = new Candidacy(); cd.Advertisement = db.Advertisements.FirstOrDefault(a => a.Id == adId); cd.Date = DateTime.Now; cd.User = currentUser; cd.IsDeleted = 0; db.Candidacies.Add(cd); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Your application has been sent !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); return(RedirectToAction("Show", "Advertisement", new { id = adId })); }
public async Task <ActionResult> Apply() { Result result = new Result(); Candidacy candidacy = new Candidacy(); if (HttpContext.Request.Form.AllKeys.Any()) { String dataCandidacy = HttpContext.Request.Form["Candidacy"]; candidacy = JsonConvert.DeserializeObject <Candidacy>(dataCandidacy); } if (HttpContext.Request.Files.AllKeys.Any()) { HttpPostedFileBase httpPostedFileImage = HttpContext.Request.Files["UploadImage"]; if (httpPostedFileImage != null) { MemoryStream msAvatar = new MemoryStream(); httpPostedFileImage.InputStream.CopyTo(msAvatar); candidacy.Avatar = msAvatar; } HttpPostedFileBase httpPostedFileCV = HttpContext.Request.Files["UploadCV"]; if (httpPostedFileCV != null) { MemoryStream msCV = new MemoryStream(); httpPostedFileCV.InputStream.CopyTo(msCV); candidacy.CV = msCV; } } if (candidacy == null) { return(Json(new Result() { Status = false, Error = "Le modèle de données renvoi null" }, JsonRequestBehavior.AllowGet)); } if (candidacy.Contact == null) { return(Json(new Result() { Status = false, Error = "Des informations sont incorects dans vos coordonnées" }, JsonRequestBehavior.AllowGet)); } if (!AddContact(candidacy.Contact)) { return(Json(new Result() { Status = false, Error = "L'ajout en base de vos coordonnées a échoué" }, JsonRequestBehavior.AllowGet)); } int idContact = GetIdContact(candidacy.Contact.Email); if (idContact == -1) { return(Json(new Result() { Status = false, Error = "La récupération de l'id de vos coordonnées a échoué" }, JsonRequestBehavior.AllowGet)); } using (SqlCommand command = new SqlCommand(String.Empty, connectionDbLocal)) { command.CommandText = "INSERT INTO [Candidacy] VALUES(@IdContact, @Formations, @Experiences, @Date, @Skills, @OtherInformation)"; command.Parameters.AddWithValue("@IdContact", idContact); command.Parameters.AddWithValue("@Formations", String.Join(", ", candidacy.Formations.Select(f => f.Value))); command.Parameters.AddWithValue("@Experiences", String.Join(", ", candidacy.Experiences.Select(e => e.Value))); command.Parameters.AddWithValue("@Date", DateTime.Now); command.Parameters.AddWithValue("@Skills", candidacy.Skills); command.Parameters.AddWithValue("@OtherInformation", candidacy.OtherInformation); if (command.ExecuteNonQuery() > 0) { await Helpers.Email.SendEmail(candidacy); } else { return(Json(new Result() { Status = false, Error = "Une erreur est survenue lors de l'ajout en base de votre candidature" }, JsonRequestBehavior.AllowGet)); } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public Ballot(PersonName voterName, Candidacy candidacy) : this(0, voterName, candidacy) { }
public Ballot(int id, PersonName voterName, Candidacy candidacy) { Id = id; Voter = voterName; Candidacy = candidacy; }