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> 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> 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 IActionResult Edit(Advertisement ad) { if (ModelState.IsValid) { db.Update(ad); db.SaveChanges(); toastNotification.AddSuccessToastMessage("Job Updated !", new NotyOptions { Theme = "metroui", Timeout = 1500, Layout = "topCenter" }); return(RedirectToAction("Show", ad.Id)); } return(View(ad)); }