public ActionResult SaveUserSkills(SkillsVM skillsVM) { if (!ModelState.IsValid) { return(HttpNotFound()); } try { UserDetails user = db.UserDetails.FirstOrDefault(x => x.UserID == skillsVM.UserID); if (user == null) { return(HttpNotFound()); } var skillIdsList = db.Skills.Where(x => skillsVM.SkillNames.Contains(x.SkillName)).Select(m => m.SkillID).ToList(); List <Skill> refer = new List <Skill>(); foreach (var item in skillIdsList) { refer.Add(db.Skills.FirstOrDefault(x => x.SkillID == item)); } user.Skills.AddRange(refer); db.SaveChanges(); return(Json("SUCCESS", JsonRequestBehavior.AllowGet)); } catch (Exception) { return(HttpNotFound()); } }
public ActionResult SkiCerfLang() { //Skills History FETCH FROM DATABASE if NOTHING KEEP AS NULL SkillsVM vm = new SkillsVM(); int id = (int)Session["IdSelected"]; List <Skill> skills = _resumeRepository.GetSkillsById(id).ToList(); int number = skills.Count; SkillsVM[] OldSkillsArray = new SkillsVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Skill, SkillsVM>()); OldSkillsArray[i] = Mapper.Map <SkillsVM>(skills[i]); } TempData["SkillsHistory"] = OldSkillsArray; //Certificaton History FROM DATABASE IF NOTHING KEEP AS NULL List <Certification> allcertifications = _resumeRepository.GetCertificationsById(id).ToList(); number = allcertifications.Count; List <CertificationsVM> OldcertificationArray = new List <CertificationsVM>(); for (int i = 0; i < number; i++) { OldcertificationArray.Add(new CertificationsVM()); OldcertificationArray[i].CertificationName = allcertifications[i].CertificateName; OldcertificationArray[i].CertificateAuthority = allcertifications[i].CertificationAuthority; OldcertificationArray[i].LevelCertification = allcertifications[i].CertificationLevel; } TempData["CertificatesHistory"] = OldcertificationArray.ToArray(); //Languages History FROM DATABASE IF NOTHING KEEP AS NULL List <Language> alllanguages = _resumeRepository.GetLanguagesById(id).ToList(); number = alllanguages.Count; LanguageVM[] OldLanguagesArray = new LanguageVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Language, LanguageVM>()); OldLanguagesArray[i] = Mapper.Map <LanguageVM>(alllanguages[i]); } TempData["LanguageHistory"] = OldLanguagesArray; return(View()); }
public async Task <ActionResult <Skill> > PostSkill(SkillsVM model) { var skill = new Skill() { SkillName = model.skillName, Description = model.skillDescription }; _context.Skills.Add(skill); var result = await _context.SaveChangesAsync(); return(Ok(result)); }
public SkillsVM AddSkill(SkillsVM skillsVM) { var skill = new Skill { Name = skillsVM.Name, ChargeAmount = skillsVM.ChargeAmount, PayAmount = skillsVM.PayAmount, IsActive = true }; _context.Skills.Add(skill); _context.SaveChanges(); skillsVM.Id = skill.Id; skillsVM.IsActive = true; return(skillsVM); }
public JsonResult GetSkillsLists() { //var sa = new JsonSerializerSettings(); var list = _IBOCountry.GetSkillsLists(); List <SkillsVM> objList = new List <SkillsVM>(); foreach (var item in list) { var svm = new SkillsVM() { skillId = item.skillId, skillName = item.skillName }; objList.Add(svm); } return(Json(objList, new JsonSerializerSettings())); }
public void UpdateSkill(SkillsVM skillVM) { var skill = _context.Skills.FirstOrDefault(s => s.Id == skillVM.Id); if (skill == null) { throw new KeyNotFoundException(); } skill.Name = skillVM.Name; skill.ChargeAmount = skillVM.ChargeAmount; skill.PayAmount = skillVM.PayAmount; skill.IsActive = skillVM.IsActive; _context.Update(skill); _context.SaveChanges(); }
public ActionResult <SkillsVM> CreateSkill(SkillsVM skillVM) { if (ModelState.IsValid) { try { if (_skillsRepo.SkillAlreadyExists(skillVM.Name)) { return(BadRequest(new { message = $"Skill {skillVM.Name} already exists" })); } var result = _skillsRepo.AddSkill(skillVM); return(Ok(result)); } catch (Exception e) { return(StatusCode(500, new { message = e.Message })); } } return(BadRequest()); }
//STEP 4.1 POST //SkillsHistory public ActionResult AddSkill(SkillsVM skill) { int idPer = (int)Session["IdSelected"]; string msg = string.Empty; //Creating Mapping Mapper.Initialize(cfg => cfg.CreateMap <SkillsVM, Skill>()); Skill skillEntity = Mapper.Map <Skill>(skill); if (_resumeRepository.AddSkill(skillEntity, idPer)) { msg = "skill added successfully"; } else { msg = "something Wrong"; } return(RedirectToAction("SkiCerfLang")); }
public ActionResult AddSkill(SkillsVM skill) { int idPer = (int)Session["IdSelected"]; string msg = string.Empty; AutoMapper.Mapper.Initialize(cfg => cfg.CreateMap <SkillsVM, SKILL>()); SKILL skillEntity = AutoMapper.Mapper.Map <SKILL>(skill); if (resumeRepo.AddSkill(skillEntity, idPer)) { msg = "skill added Successfully"; } else { msg = "something Wrong"; } return(Json(new { data = msg }, JsonRequestBehavior.AllowGet)); }
public async void TestPostSkills() { var options = new DbContextOptionsBuilder <Databasecontext >().UseInMemoryDatabase(databaseName: "Test3") .Options; using (var context = new Databasecontext(options)) { var skill = new SkillsVM() { skillId = "1", skillName = "test", skillDescription = "test" }; SkillsController Skills = new SkillsController(context); await Skills.PostSkill(skill); var find = context.Skills.Find(1); Assert.Equal(1, find.SkillId); } }
public IActionResult Put(int id, SkillsVM skillsVM) { if (ModelState.IsValid) { if (id != skillsVM.Id) { return(BadRequest()); } try { if (_skillsRepo.SkillAlreadyExists(skillsVM.Name, id)) { return(BadRequest(new { message = $"Skill {skillsVM.Name} already exists" })); } _skillsRepo.UpdateSkill(skillsVM); return(Ok()); } catch (DbUpdateConcurrencyException) { if (!_skillsRepo.SkillExists(id)) { return(NotFound()); } } catch (KeyNotFoundException) { return(NotFound()); } catch (Exception e) { return(StatusCode(500, new { status = 500, message = e.Message })); } return(NoContent()); } return(BadRequest()); }
// GET: PDF public ActionResult standardPDF() { int id = (int)Session["IdSelected"]; //////////////////////////////////////// Mapper.Initialize(cfg => cfg.CreateMap <Person, PersonVM>()); Person p = _resumeRepository.GetPersonalInformation(id); PersonVM pvm = Mapper.Map <PersonVM>(p); pvm.Tel = p.TelephoneNumber; pvm.FaceBookProfil = p.FacebookProfile; pvm.LinkedInProdil = p.LinkedinProfile; pvm.ImagePath = p.ProfilePicture; ViewBag.Person = pvm; //////////////////////////////////////// List <Education> educations = _resumeRepository.GetEducationByID(id).ToList(); int number = educations.Count; EducationVM[] OldArrayEdu = new EducationVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Education, EducationVM>()); OldArrayEdu[i] = Mapper.Map <EducationVM>(educations[i]); OldArrayEdu[i].TitleOfDiploma = educations[i].Title; OldArrayEdu[i].InstituteUniversity = educations[i].InstituteName; } ViewBag.educationArray = OldArrayEdu; //////////////////////////////////////// List <WorkExperience> works = _resumeRepository.GetWorkExperiencesById(id).ToList(); number = works.Count; WorkExperienceVM[] OldArraywork = new WorkExperienceVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <WorkExperience, WorkExperienceVM>()); OldArraywork[i] = Mapper.Map <WorkExperienceVM>(works[i]); } ViewBag.workArray = OldArraywork; /////////////////////////////////////// List <Skill> skills = _resumeRepository.GetSkillsById(id).ToList(); number = skills.Count; SkillsVM[] OldSkillsArray = new SkillsVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Skill, SkillsVM>()); OldSkillsArray[i] = Mapper.Map <SkillsVM>(skills[i]); } ViewBag.skillsArray = OldSkillsArray; /////////////////////////////////////// List <Certification> allcertifications = _resumeRepository.GetCertificationsById(id).ToList(); number = allcertifications.Count; CertificationsVM[] OldcertificationArray = new CertificationsVM[number]; for (int i = 0; i < number; i++) { OldcertificationArray[i] = new CertificationsVM(); OldcertificationArray[i].CertificationName = allcertifications[i].CertificateName; OldcertificationArray[i].CertificateAuthority = allcertifications[i].CertificationAuthority; OldcertificationArray[i].LevelCertification = allcertifications[i].CertificationLevel; } ViewBag.certificatesArray = OldcertificationArray; /////////////////////////////////////// List <Language> alllanguages = _resumeRepository.GetLanguagesById(id).ToList(); number = alllanguages.Count; LanguageVM[] OldLanguagesArray = new LanguageVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Language, LanguageVM>()); OldLanguagesArray[i] = Mapper.Map <LanguageVM>(alllanguages[i]); } ViewBag.languagesArray = OldLanguagesArray; //string s =Path.GetFileName(Request.Url.AbsolutePath); //NReco.PdfGenerator.HtmlToPdfConverter htmlTo = new NReco.PdfGenerator.HtmlToPdfConverter(); //string html = gethtml("localhost:57666/PDF/standardPDF"); //var pdfBytes = (new NReco.PdfGenerator.HtmlToPdfConverter()).GeneratePdf(html); //System.IO.File.WriteAllBytes("hello.pdf", pdfBytes); return(View()); }
public ActionResult compactPDF() { int id = (int)Session["IdSelected"]; //////////////////////////////////////// Mapper.Initialize(cfg => cfg.CreateMap <Person, PersonVM>()); Person p = _resumeRepository.GetPersonalInformation(id); PersonVM pvm = Mapper.Map <PersonVM>(p); pvm.Tel = p.TelephoneNumber; pvm.FaceBookProfil = p.FacebookProfile; pvm.LinkedInProdil = p.LinkedinProfile; pvm.ImagePath = p.ProfilePicture; ViewBag.Person = pvm; //////////////////////////////////////// List <Education> educations = _resumeRepository.GetEducationByID(id).ToList(); int number = educations.Count; EducationVM[] OldArrayEdu = new EducationVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Education, EducationVM>()); OldArrayEdu[i] = Mapper.Map <EducationVM>(educations[i]); OldArrayEdu[i].TitleOfDiploma = educations[i].Title; OldArrayEdu[i].InstituteUniversity = educations[i].InstituteName; } ViewBag.educationArray = OldArrayEdu; //////////////////////////////////////// List <WorkExperience> works = _resumeRepository.GetWorkExperiencesById(id).ToList(); number = works.Count; WorkExperienceVM[] OldArraywork = new WorkExperienceVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <WorkExperience, WorkExperienceVM>()); OldArraywork[i] = Mapper.Map <WorkExperienceVM>(works[i]); } ViewBag.workArray = OldArraywork; /////////////////////////////////////// List <Skill> skills = _resumeRepository.GetSkillsById(id).ToList(); number = skills.Count; SkillsVM[] OldSkillsArray = new SkillsVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Skill, SkillsVM>()); OldSkillsArray[i] = Mapper.Map <SkillsVM>(skills[i]); } ViewBag.skillsArray = OldSkillsArray; /////////////////////////////////////// List <Certification> allcertifications = _resumeRepository.GetCertificationsById(id).ToList(); number = allcertifications.Count; CertificationsVM[] OldcertificationArray = new CertificationsVM[number]; for (int i = 0; i < number; i++) { OldcertificationArray[i] = new CertificationsVM(); OldcertificationArray[i].CertificationName = allcertifications[i].CertificateName; OldcertificationArray[i].CertificateAuthority = allcertifications[i].CertificationAuthority; OldcertificationArray[i].LevelCertification = allcertifications[i].CertificationLevel; } ViewBag.certificatesArray = OldcertificationArray; /////////////////////////////////////// List <Language> alllanguages = _resumeRepository.GetLanguagesById(id).ToList(); number = alllanguages.Count; LanguageVM[] OldLanguagesArray = new LanguageVM[number]; for (int i = 0; i < number; i++) { Mapper.Initialize(cfg => cfg.CreateMap <Language, LanguageVM>()); OldLanguagesArray[i] = Mapper.Map <LanguageVM>(alllanguages[i]); } ViewBag.languagesArray = OldLanguagesArray; return(View()); }
public async Task <IActionResult> Skills(int?id) { var user = await _userManager.GetUserAsync(User); Profile currentProfile = null; int currentId = 0; int profileId = 0; if (_signInManager.IsSignedIn(User)) { currentProfile = db.Profile.First(p => p.UsersId == user.Id); currentId = currentProfile.id; } if (id == null) { if (_signInManager.IsSignedIn(User)) { profileId = currentId; } else { return(RedirectToAction("Index", "Home")); } } else { profileId = (int)id; } var profile = db.Profile.FirstOrDefault(p => p.id == profileId); var thisuser = db.Users.FirstOrDefault(u => u.Id == profile.UsersId); if (_signInManager.IsSignedIn(User)) { var block = db.Blocklist.FirstOrDefault(b => b.blockedId == user.Id && b.blockerId == thisuser.Id || b.blockerId == user.Id && b.blockedId == thisuser.Id); if (block != null) { return(RedirectToAction("Index", "Home")); } } if (profile.Disabled && profile.UsersId != user.Id) { return(RedirectToAction("Index", "Home")); } if (currentProfile != null && currentProfile.Disabled) { return(RedirectToAction("Ban", "Home", new { profile.id })); } var skillHeaders = db.SkillsHeader.Where(sk => sk.ProfileId == profile.id).ToList(); skillHeaders.Reverse(); // Get profile Cover information bool isfolowing = false; if (user != null) { var folow = db.Follow.FirstOrDefault(f => f.folowerId == currentProfile.id && f.folowingId == profile.id); if (folow != null) { isfolowing = true; } } var coverClass = new CoverClass() { Profile = profile, User = db.Users.FirstOrDefault(u => u.Id == profile.UsersId), folowings = db.Follow.Where(f => f.folowerId == profile.id).Count(), folowers = db.Follow.Where(f => f.folowingId == profile.id).Count(), views = profile.View, isFolowing = isfolowing }; // preparing skills model var model = new SkillsVM() { Position = db.Position.ToList(), SkillsHeader = skillHeaders, SkillsHeaderPosition = db.SkillsHeaderPosition.ToList(), CoverClass = coverClass, UserLanguages = db.UsersLanguages.Where(ul => ul.UsersId == profile.UsersId).ToList(), Languages = db.Languages.ToList() }; bool isAjaxCall = Request.Headers["x-requested-with"] == "XMLHttpRequest"; if (isAjaxCall) { return(PartialView("_Skills", model)); } else { return(View(model)); } }