public async Task <IActionResult> Edit(Education model) { var header = this.Request.Headers["sec-fetch-site"]; if (header == "none") { return(RedirectToAction("Index", "Advertisement")); } if (ModelState.IsValid) { Education entity = db.Educations.FirstOrDefault(e => e.Id == model.Id); entity.InstitutionName = model.InstitutionName; entity.StartYear = model.StartYear; entity.EndYear = model.EndYear; entity.DiplomaTitle = model.DiplomaTitle; entity.Description = model.Description; db.Update <Education>(entity); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Education experience info edited !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } return(PartialView("_Edit", model)); }
public async Task <IActionResult> Edit(ProfSkill model) { var header = this.Request.Headers["sec-fetch-site"]; if (header == "none") { return(RedirectToAction("Index", "Advertisement")); } if (ModelState.IsValid) { ProfSkill entity = db.ProfSkills.FirstOrDefault(e => e.Id == model.Id); entity.Name = model.Name; entity.Percent = model.Percent; db.Update <ProfSkill>(entity); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Professional Skill Updated !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } return(PartialView("_Edit", model)); }
public async Task <IActionResult> Edit(LanguageViewModel model) { var header = this.Request.Headers["sec-fetch-site"]; if (header == "none") { return(RedirectToAction("Index", "Advertisement")); } if (ModelState.IsValid) { Language entity = db.Languages.FirstOrDefault(e => e.Id == model.language.Id); entity.LanguageName = model.language.LanguageName; entity.ProfeciencyLevel = model.language.ProfeciencyLevel; db.Update <Language>(entity); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Language Edited !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } return(PartialView("_Edit", model)); }
public async Task <IActionResult> EditCandidateProfile(EditCandidateProfileViewModel model) { ModelState.MarkAllFieldsAsSkipped("Password"); var user = await signInManager.UserManager.GetUserAsync(this.User); if (user == null) { return(RedirectToAction("Login", "Account")); } if (model.ImageFile == null) { model.Candidate.Picture = user.Picture; } if (ModelState.IsValid) { try { if (model.ImageFile != null) { string imageFileName = new string(Path.GetFileNameWithoutExtension(model.ImageFile.FileName).Take(10).ToArray()).Replace(' ', '-'); string newFileName = imageFileName + '-' + Guid.NewGuid().ToString() + '.' + Path.GetExtension(model.ImageFile.FileName); string destination = Path.Combine(hostEnvironment.WebRootPath, "uploads/UserImages"); destination = Path.Combine(destination, newFileName); using (var fileStream = new FileStream(destination, FileMode.Create)) { model.ImageFile.CopyTo(fileStream); } user.Picture = newFileName; } user.Firstname = model.Candidate.Firstname; user.Lastname = model.Candidate.Lastname; user.Email = model.Candidate.Email; user.Address = model.Candidate.Address; user.PhoneNumber = model.Candidate.PhoneNumber; db.Update <User>(user); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("User Updated !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); return(RedirectToAction("EditCandidateProfile")); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(View(model)); }
public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } var ad = await db.Advertisements.SingleOrDefaultAsync(a => a.Id == id); var user = await signInManager.UserManager.GetUserAsync(signInManager.Context.User); if (ad == null) { return(NotFound()); } if (!ad.UserId.Equals(user.Id)) { return(RedirectToAction("Index")); } db.Advertisements.Remove(ad); await db.SaveChangesAsync(); toastNotification.AddSuccessToastMessage("Job Deleted", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> AddOrEdit(SocialMedia model) { var header = this.Request.Headers["sec-fetch-site"]; if (header == "none") { return(RedirectToAction("Index", "Advertisement")); } bool update = true; SocialMedia entity = null; if (ModelState.IsValid) { User currentUser = await signInManager.UserManager.GetUserAsync(this.User); if (model.Id == 0) { entity = new SocialMedia(); entity.UserId = currentUser.Id; update = false; } else { entity = db.SocialMedias.FirstOrDefault(s => s.Id == currentUser.SocialMedia.Id); } entity.Facebook = model.Facebook; entity.Behance = model.Behance; entity.Dribbble = model.Dribbble; entity.Github = model.Github; entity.Linkedin = model.Linkedin; entity.Twitter = model.Twitter; entity.Youtube = model.Youtube; entity.Instagram = model.Instagram; entity.Pintrest = model.Pintrest; if (update) { db.Update <SocialMedia>(entity); toastNotification.AddSuccessToastMessage("Social Media Link Updated !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } else { await db.AddAsync <SocialMedia>(entity); toastNotification.AddSuccessToastMessage("Social Media Link Added !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); } await db.SaveChangesAsync(); } return(PartialView("_AddOrEdit", model)); }
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 })); }