Application To Build Resume/CV With ASP.NET MVC 5 And jQuery

Introduction

In this article, we will demonstrate how we can build an application that creates the CV. As you know, resume/CV has different parts, such as - personal information, education, work experiences, skills, certifications, languages. We are using ASP.NET MVC 5, jQuery, and Bootstrap in order to build our application. I hope you will like it.

 

 

Prerequisites

Make sure you have installed Visual Studio 2015 (.NET Framework 4.5.2) and SQL Server. In this post, we are going to:

  • Create Database.
  • Create MVC application.
  • Configuring Entity framework ORM to connect to the database.
  • Create repository.
  • Create resume controller.
  • Adding all the needed pages in order to build our application.

SQL Database part

The database script is included in the source code of our project.

Create your MVC application

Open Visual Studio and select File >> New Project.

The "New Project" window will pop up. Select ASP.NET Web Application (.NET Framework), name your project, and click OK.

ASP.NET

Next, a new dialog will pop up for selecting the template. We are going choose MVC template and click OK.

ASP.NET

Once our project is created, we will add ADO.NET Entity Data Model.

Adding ADO.NET Entity Data Model

Right-click on the project name, click Add >> Add New Item.

A dialog box will pop up. Inside Visual C#, select Data >> ADO.NET Entity Data Model, and enter the name for your DbContext model as Resume, then click Add.

ASP.NET

As you can see, we have 4 model contents. We are selecting the first approach (EF Designer from the database).

ASP.NET

As you can see below, we need to select server name, then via drop down list, connect to a database section. You must choose your database name and finally click OK.

ASP.NET

For the next step, the dialog Entity Data Model Wizard will pop up for choosing objects which will be used in our application. We are selecting all the tables followed by a click on "Finish" button.

Finally, we see that EDMX model generates all the objects, as shown below.

ASP.NET

ASP.NET

Create repository

After generating our Edmx file, the next step is to create all methods which will be used in our application.

First, we need to create repository folder. To do that, from solution explorer, right click on project name >> Add >> New Folder (you can name it as you like).

Now, we will add IResumeRepository interface which contains all the methods that should be implemented in our ResumeRepository class.

IResumeRepository.cs

  1. using ResumeMVC.EDMXModel;  
  2. using System;  
  3. using System.Collections.Generic;  
  4. using System.Linq;  
  5. using System.Text;  
  6. using System.Threading.Tasks;  
  7. using System.Web;  
  8.   
  9. namespace ResumeMVC.Repository  
  10. {  
  11.    public interface IResumeRepository  
  12.     {  
  13.         bool AddPersonnalInformation(Person person, HttpPostedFileBase file);  
  14.         string AddOrUpdateEducation(Education education, int idPer);  
  15.         int GetIdPerson(string firstName, string lastName);  
  16.         string AddOrUpdateExperience(WorkExperience workExperience, int idPer);  
  17.         bool AddSkill(Skill skill, int idPer);  
  18.         bool AddCertification(Certification certification, int idPer);  
  19.         bool AddLanguage(Language language, int idPer);  
  20.         Person GetPersonnalInfo(int idPer);  
  21.         IQueryable<Education> GetEducationById(int idPer);  
  22.         IQueryable<WorkExperience> GetWorkExperienceById(int idPer);  
  23.         IQueryable<Skill> GetSkillsById(int idPer);  
  24.         IQueryable<Certification> GetCertificationsById(int idPer);  
  25.         IQueryable<Language> GetLanguageById(int idPer);  
  26.     }  
  27. }  

ResumeRepository.cs

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using ResumeMVC.EDMXModel;  
  6. using System.IO;  
  7. using System.Data.Entity.Validation;  
  8. using System.Data.Entity;  
  9. using AutoMapper.QueryableExtensions;  
  10. using ResumeMVC.ViewModels;  
  11.   
  12. namespace ResumeMVC.Repository  
  13. {  
  14.     public class ResumeRepository : IResumeRepository  
  15.     {  
  16.         //Db Context  
  17.         private readonly DBCVEntities _dbContext = new DBCVEntities();  
  18.   
  19.         public bool AddCertification(Certification certification, int idPer)  
  20.         {  
  21.             try  
  22.             {  
  23.                 int countRecords = 0;  
  24.                 Person personEntity = _dbContext.People.Find(idPer);  
  25.   
  26.                 if (personEntity != null && certification != null)  
  27.                 {  
  28.                     personEntity.Certifications.Add(certification);  
  29.                     countRecords = _dbContext.SaveChanges();  
  30.                 }  
  31.   
  32.                 return countRecords > 0 ? true : false;  
  33.             }  
  34.             catch (DbEntityValidationException dbEx)  
  35.             {  
  36.   
  37.                 throw;  
  38.             }  
  39.              
  40.         }  
  41.   
  42.         public bool AddLanguage(Language language, int idPer)  
  43.         {  
  44.                 int countRecords = 0;  
  45.                 Person personEntity = _dbContext.People.Find(idPer);  
  46.   
  47.                 if (personEntity != null && language != null)  
  48.                 {  
  49.                     personEntity.Languages.Add(language);  
  50.                     countRecords = _dbContext.SaveChanges();  
  51.                 }  
  52.   
  53.                 return countRecords > 0 ? true : false;  
  54.         }  
  55.   
  56.         public string AddOrUpdateEducation(Education education, int idPer)  
  57.         {  
  58.             string msg = string.Empty;  
  59.   
  60.             Person personEntity = _dbContext.People.Find(idPer);  
  61.   
  62.             if(personEntity != null)  
  63.             {  
  64.                 if (education.IDEdu > 0)  
  65.                 {  
  66.                     //we will update education entity  
  67.                     _dbContext.Entry(education).State = EntityState.Modified;  
  68.                     _dbContext.SaveChanges();  
  69.   
  70.                     msg = "Education entity has been updated successfully";  
  71.                 }  
  72.                 else  
  73.                 {  
  74.                     // we will add new education entity  
  75.                     personEntity.Educations.Add(education);  
  76.                     _dbContext.SaveChanges();  
  77.   
  78.                     msg = "Education entity has been Added successfully";  
  79.                 }  
  80.             }  
  81.   
  82.             return msg;  
  83.         }  
  84.   
  85.         public string AddOrUpdateExperience(WorkExperience workExperience, int idPer)  
  86.         {  
  87.             string msg = string.Empty;  
  88.   
  89.             Person personEntity = _dbContext.People.Find(idPer);  
  90.   
  91.             if (personEntity != null)  
  92.             {  
  93.                 if (workExperience.IDExp > 0)  
  94.                 {  
  95.                     //we will update work experience entity  
  96.                     _dbContext.Entry(workExperience).State = EntityState.Modified;  
  97.                     _dbContext.SaveChanges();  
  98.   
  99.                     msg = "Work Experience entity has been updated successfully";  
  100.                 }  
  101.                 else  
  102.                 {  
  103.                     // we will add new work experience entity  
  104.                     personEntity.WorkExperiences.Add(workExperience);  
  105.                     _dbContext.SaveChanges();  
  106.   
  107.                     msg = "Work Experience entity has been Added successfully";  
  108.                 }  
  109.             }  
  110.   
  111.             return msg;  
  112.         }  
  113.   
  114.         public bool AddPersonnalInformation(Person person, HttpPostedFileBase file)  
  115.         {  
  116.             try  
  117.             {  
  118.                 int nbRecords = 0;  
  119.   
  120.                 if (person != null)  
  121.                 {  
  122.                     if (file != null)  
  123.                     {  
  124.                         person.Profil = ConvertToBytes(file);  
  125.                     }  
  126.   
  127.                     _dbContext.People.Add(person);  
  128.                     nbRecords = _dbContext.SaveChanges();  
  129.                 }  
  130.   
  131.                 return nbRecords > 0 ? true : false;  
  132.             }  
  133.             catch (DbEntityValidationException dbEx)  
  134.             {  
  135.   
  136.                 Exception raise = dbEx;  
  137.                 foreach (var validationErrors in dbEx.EntityValidationErrors)  
  138.                 {  
  139.                     foreach (var validationError in validationErrors.ValidationErrors)  
  140.                     {  
  141.                         string message = string.Format("{0}:{1}",  
  142.                             validationErrors.Entry.Entity.ToString(),  
  143.                             validationError.ErrorMessage);  
  144.                         // raise a new exception nesting  
  145.                         // the current instance as InnerException  
  146.                         raise = new InvalidOperationException(message, raise);  
  147.                     }  
  148.                 }  
  149.                 throw raise;  
  150.             }  
  151.               
  152.         }  
  153.   
  154.         public bool AddSkill(Skill skill, int idPer)  
  155.         {  
  156.             int countRecords = 0;  
  157.             Person personEntity = _dbContext.People.Find(idPer);  
  158.   
  159.             if(personEntity != null && skill != null)  
  160.             {  
  161.                 personEntity.Skills.Add(skill);  
  162.                 countRecords = _dbContext.SaveChanges();  
  163.             }  
  164.   
  165.             return countRecords > 0 ? true : false;  
  166.   
  167.         }  
  168.   
  169.         public IQueryable<Certification> GetCertificationsById(int idPer)  
  170.         {  
  171.             var certificationList = _dbContext.Certifications.Where(w => w.IdPers == idPer);  
  172.             return certificationList;  
  173.         }  
  174.   
  175.         public IQueryable<Education> GetEducationById(int idPer)  
  176.         {  
  177.             var educationList = _dbContext.Educations.Where(e => e.IdPers == idPer);  
  178.             return educationList;  
  179.         }  
  180.   
  181.         public int GetIdPerson(string firstName, string lastName)  
  182.         {  
  183.             int idSelected = _dbContext.People.Where(p => p.FirstName.ToLower().Equals(firstName.ToLower()))  
  184.                                               .Where(p => p.LastName.ToLower().Equals(lastName.ToLower()))  
  185.                                               .Select(p => p.IDPers).FirstOrDefault();  
  186.   
  187.             return idSelected;  
  188.         }  
  189.   
  190.         public IQueryable<Language> GetLanguageById(int idPer)  
  191.         {  
  192.             var languageList = _dbContext.Languages.Where(w => w.IdPers == idPer);  
  193.             return languageList;  
  194.         }  
  195.   
  196.         public Person GetPersonnalInfo(int idPer)  
  197.         {  
  198.             return _dbContext.People.Find(idPer);  
  199.         }  
  200.   
  201.         public IQueryable<Skill> GetSkillsById(int idPer)  
  202.         {  
  203.             var skillsList = _dbContext.Skills.Where(w => w.IdPers == idPer);  
  204.             return skillsList;  
  205.         }  
  206.   
  207.         public IQueryable<WorkExperience> GetWorkExperienceById(int idPer)  
  208.         {  
  209.             var workExperienceList = _dbContext.WorkExperiences.Where(w => w.IDPers == idPer);  
  210.             return workExperienceList;  
  211.         }  
  212.   
  213.         private byte[] ConvertToBytes(HttpPostedFileBase image)  
  214.         {  
  215.             byte[] imageBytes = null;  
  216.             BinaryReader reader = new BinaryReader(image.InputStream);  
  217.             imageBytes = reader.ReadBytes((int)image.ContentLength);  
  218.             return imageBytes;  
  219.         }  
  220.   
  221.     }  
  222. }  

Note
Do not forget to add the following View Models.

To do that, from solution explorer, right click on project name >> Add >> New Folder.

CertificationVM.cs

  1. public class CertificationVM  
  2. {  
  3.     [Required(ErrorMessage = "Please Your Certification name")]  
  4.     public string CertificationName { get; set; }  
  5.   
  6.     [Required(ErrorMessage = "Please enter Certification Authority")]  
  7.     public string CertificationAuthority { get; set; }  
  8.   
  9.     [Required(ErrorMessage = "Please select Certification Level")]  
  10.     public string LevelCertification { get; set; }  
  11.   
  12.     [Required(ErrorMessage = "Please select achievement date")]  
  13.     public Nullable<System.DateTime> FromYear { get; set; }  
  14.   
  15.     public List<SelectListItem> ListOfLevel { get; set; }  
  16. }  

EducationVM.cs

  1. public class EducationVM  
  2. {  
  3.   
  4.     public int IDEdu { get; set; }  
  5.   
  6.     [Required(ErrorMessage = "Please Your Institute or university")]  
  7.     public string InstituteUniversity { get; set; }  
  8.   
  9.     [Required(ErrorMessage = "Please Your Title of diploma")]  
  10.     public string TitleOfDiploma { get; set; }  
  11.   
  12.     [Required(ErrorMessage = "Please Your Degree")]  
  13.     public string Degree { get; set; }  
  14.   
  15.     [Required(ErrorMessage = "Please enter Start Year")]  
  16.     public Nullable<System.DateTime> FromYear { get; set; }  
  17.   
  18.     [Required(ErrorMessage = "Please enter End Year")]  
  19.     public Nullable<System.DateTime> ToYear { get; set; }  
  20.     [Required(ErrorMessage = "Please enter City")]  
  21.     public string City { get; set; }  
  22.     [Required(ErrorMessage = "Please enter Country")]  
  23.     public string Country { get; set; }  
  24.   
  25.     public List<SelectListItem> ListOfCountry { get; set; }  
  26.     public List<SelectListItem> ListOfCity { get; set; }  
  27.   
  28. }  

LanguageVM.cs

  1. public class LanguageVM  
  2. {  
  3.     [Required(ErrorMessage = "Please enter Language Name")]  
  4.     public string LanguageName { get; set; }  
  5.   
  6.     [Required(ErrorMessage = "Please select Proficiency")]  
  7.     public string Proficiency { get; set; }  
  8.   
  9.     public List<SelectListItem> ListOfProficiency { get; set; }  
  10. }  

PersonVM.cs

  1. public class PersonVM  
  2. {  
  3.     public int IDPers { get; set; }  
  4.   
  5.     [Required(ErrorMessage = "Please Your First Name ")]  
  6.     public string FirstName { get; set; }  
  7.     [Required(ErrorMessage = "Please Your Last Name ")]  
  8.     public string LastName { get; set; }  
  9.     [Required(ErrorMessage = "Please Your Date Of Birth ")]  
  10.     public Nullable<System.DateTime> DateOfBirth { get; set; }  
  11.   
  12.     [Required(ErrorMessage = "Please Your Nationality ")]  
  13.     public string Nationality { get; set; }  
  14.   
  15.     [Required(ErrorMessage = "Select Your Educational Level ")]  
  16.     public string EducationalLevel { get; set; }  
  17.   
  18.     [Required(ErrorMessage = "Please Your Address ")]  
  19.     public string Address { get; set; }  
  20.   
  21.     [Required(ErrorMessage = "Please Your Phone Number ")]  
  22.     public string Tel { get; set; }  
  23.   
  24.     [Required(ErrorMessage = "Please Your Email Address ")]  
  25.     public string Email { get; set; }  
  26.   
  27.     [Required(ErrorMessage = "Please Your Summary")]  
  28.     [DataType(DataType.MultilineText)]  
  29.     public string Summary { get; set; }  
  30.   
  31.     [Required(ErrorMessage = "Please Your LinekedIn Profil")]  
  32.     [DataType(DataType.Url)]  
  33.     public string LinkedInProdil { get; set; }  
  34.   
  35.     [Required(ErrorMessage = "Please Your Facebook Profil")]  
  36.     [DataType(DataType.Url)]  
  37.     public string FaceBookProfil { get; set; }  
  38.   
  39.     [Required(ErrorMessage = "Please Your C# Corner Profil")]  
  40.     [DataType(DataType.Url)]  
  41.     public string C_CornerProfil { get; set; }  
  42.   
  43.     [Required(ErrorMessage = "Please Your Twitter Profil")]  
  44.     [DataType(DataType.Url)]  
  45.     public string TwitterProfil { get; set; }  
  46.     public byte[] Profil { get; set; }  
  47.   
  48.     public List<SelectListItem> ListNationality { get; set; }  
  49.     public List<SelectListItem> ListEducationalLevel { get; set; }  
  50. }  

SkillsVM.cs

  1. public class SkillsVM  
  2. {  
  3.     [Required(ErrorMessage="Please enter your skill name")]  
  4.     public string SkillName { get; set; }  
  5. }  

WorkExperienceVM.cs

  1. public class WorkExperienceVM  
  2. {  
  3.     public int IDExp { get; set; }  
  4.   
  5.     [Required(ErrorMessage ="Please Your Company")]  
  6.     public string Company { get; set; }  
  7.   
  8.     [Required(ErrorMessage = "Please Your Title")]  
  9.     public string Title { get; set; }  
  10.   
  11.     [Required(ErrorMessage = "Please Country is required")]  
  12.     public string Country { get; set; }  
  13.   
  14.     [Required(ErrorMessage = "Please enter Start Date")]  
  15.     public Nullable<System.DateTime> FromYear { get; set; }  
  16.   
  17.     [Required(ErrorMessage = "Please enter End Date")]  
  18.     public Nullable<System.DateTime> ToYear { get; set; }  
  19.       
  20.     [Required(ErrorMessage = "Please enter Description")]  
  21.     [DataType(DataType.MultilineText)]  
  22.     public string Description { get; set; }  
  23.   
  24.     public List<SelectListItem> ListeOfCountries { get; set; }  
  25.   
  26. }  

Create a controller

Now, we are going to create a Controller. Right-click on the controllers folder> > Add >> Controller>> selecting MVC 5 Controller - Empty>> click Add. In the next dialog, name the controller as ResumeController and then click Add.

ASP.NET

ASP.NET

ResumeController.cs

Here, we should provide all the needed personal information such as first name, last name, date of birth, and nationality.

We have created two actions - personal information with httpGet which is used to get personal information view and another personal information action with httpPost that is responsible to add our object into person table.

  1. [HttpGet]  
  2. public ActionResult PersonnalInformtion(PersonVM model)  
  3. {  
  4.     //Nationality  
  5.     List<SelectListItem> nationality = new List<SelectListItem>()  
  6.     {  
  7.         new SelectListItem { Text = "Morocco", Value = "Morocco", Selected = true},  
  8.         new SelectListItem { Text = "India", Value = "India"},  
  9.         new SelectListItem { Text = "Spain", Value = "Spain"},  
  10.         new SelectListItem { Text = "USA", Value = "USA"},  
  11.     };  
  12.   
  13.   
  14.     //Educational Level  
  15.     List<SelectListItem> educationalLevel = new List<SelectListItem>()  
  16.     {  
  17.         new SelectListItem { Text = "Hight School", Value = "Hight School", Selected = true},  
  18.         new SelectListItem { Text = "Diploma", Value = "Diploma"},  
  19.         new SelectListItem { Text = "Bachelor's degree", Value = "Bachelor's degree"},  
  20.         new SelectListItem { Text = "Master's degree", Value = "Master's degree"},  
  21.         new SelectListItem { Text = "Doctorate", Value = "Doctorate"},  
  22.     };  
  23.   
  24.     model.ListNationality = nationality;  
  25.     model.ListEducationalLevel = educationalLevel;  
  26.   
  27.     return View(model);  
  28. }  
  29.   
  30. [HttpPost]  
  31. [ActionName("PersonnalInformtion")]  
  32. public ActionResult AddPersonnalInformtion(PersonVM person)  
  33. {  
  34.   
  35.     if(ModelState.IsValid)  
  36.     {  
  37.         //Creating Mapping  
  38.         Mapper.Initialize(cfg => cfg.CreateMap<PersonVM, Person>());  
  39.   
  40.         Person personEntity = Mapper.Map<Person>(person);  
  41.   
  42.         HttpPostedFileBase file = Request.Files["ImageProfil"];  
  43.   
  44.         bool result = _resumeRepository.AddPersonnalInformation(personEntity, file);  
  45.   
  46.         if(result)  
  47.         {  
  48.             Session["IdSelected"] = _resumeRepository.GetIdPerson(person.FirstName, person.LastName);  
  49.             return RedirectToAction("Education");  
  50.         }  
  51.         else  
  52.         {  
  53.             ViewBag.Message = "Something Wrong !";  
  54.             return View(person);  
  55.         }  
  56.           
  57.     }  
  58.   
  59.     ViewBag.MessageForm = "Please Check your form before submit !";  
  60.     return View(person);  
  61.   
  62. }  

ASP.NET

Here, we are using education to provide all the details. As you can see below, the education form has several fields, such as institute/university, Title of diploma, degree, etc.

We have created two actions to achieve that - education which is decorated with httpGet in order to display our education form via partial view, then education action with httpPost which will persist our education object into educations table.

  1. [HttpGet]  
  2. public ActionResult Education(EducationVM education)  
  3. {  
  4.     return View();  
  5. }  
  6.   
  7. [HttpPost]  
  8. public ActionResult AddOrUpdateEducation(EducationVM education)  
  9. {  
  10.     string msg = string.Empty;  
  11.   
  12.     if(education != null)  
  13.     {  
  14.         //Creating Mapping  
  15.         Mapper.Initialize(cfg => cfg.CreateMap<EducationVM, Education>());  
  16.         Education educationEntity = Mapper.Map<Education>(education);  
  17.   
  18.         int idPer = (int)Session["IdSelected"];  
  19.   
  20.         msg = _resumeRepository.AddOrUpdateEducation(educationEntity, idPer);  
  21.          
  22.     }  
  23.     else  
  24.     {  
  25.         msg = "Please re try the operation";  
  26.     }  
  27.   
  28.     return Json(new { data = msg }, JsonRequestBehavior.AllowGet);  
  29. }  
  30.   
  31. [HttpGet]  
  32. public PartialViewResult EducationPartial(EducationVM education)  
  33. {  
  34.   
  35.     education.ListOfCountry = GetCountries();  
  36.   
  37.     return PartialView("~/Views/Shared/_MyEducation.cshtml", education);  
  38. }  

ASP.NET

Now, we need to add user work experiences. To do that, we have created work experience action to get our View which is absolutely decorated with httpGet, then work experience action with httpPost that is responsible to add all the data of work experience into work exp table.

  1. [HttpGet]  
  2.  public ActionResult WorkExperience()  
  3.  {  
  4.      return View();  
  5.  }  
  6.   
  7.  public PartialViewResult WorkExperiencePartial(WorkExperienceVM workExperience)  
  8.  {  
  9.      workExperience.ListeOfCountries = GetCountries();  
  10.   
  11.      return PartialView("~/Views/Shared/_MyWorkExperience.cshtml", workExperience);  
  12.  }  
  13.   
  14.  public ActionResult AddOrUpdateExperience(WorkExperienceVM workExperience)  
  15.  {  
  16.   
  17.      string msg = string.Empty;  
  18.   
  19.      if (workExperience != null)  
  20.      {  
  21.          //Creating Mapping  
  22.          Mapper.Initialize(cfg => cfg.CreateMap<WorkExperienceVM, WorkExperience>());  
  23.          WorkExperience workExperienceEntity = Mapper.Map<WorkExperience>(workExperience);  
  24.   
  25.          int idPer = (int)Session["IdSelected"];  
  26.           
  27.   
  28.          msg = _resumeRepository.AddOrUpdateExperience(workExperienceEntity, idPer);  
  29.   
  30.      }  
  31.      else  
  32.      {  
  33.          msg = "Please re try the operation";  
  34.      }  
  35.   
  36.      return Json(new { data = msg }, JsonRequestBehavior.AllowGet);  
  37.  }  

ASP.NET

Finally, we are going to add the code snippet for skills, certifications, and languages.

For skills

  1. [HttpGet]  
  2. public ActionResult SkiCerfLang()  
  3. {  
  4.     return View();  
  5. }  
  6.   
  7. public PartialViewResult SkillsPartial()  
  8. {  
  9.     return PartialView("~/Views/Shared/_MySkills.cshtml");  
  10. }  
  11.   
  12. public ActionResult AddSkill(SkillsVM skill)  
  13. {  
  14.     int idPer = (int)Session["IdSelected"];  
  15.     string msg = string.Empty;  
  16.   
  17.     //Creating Mapping  
  18.     Mapper.Initialize(cfg => cfg.CreateMap<SkillsVM, Skill>());  
  19.     Skill skillEntity = Mapper.Map<Skill>(skill);  
  20.   
  21.     if (_resumeRepository.AddSkill(skillEntity, idPer))  
  22.     {  
  23.         msg = "skill added successfully";  
  24.     }  
  25.     else  
  26.     {  
  27.         msg = "something Wrong";  
  28.     }  
  29.   
  30.     return Json(new { data = msg}, JsonRequestBehavior.AllowGet);  
  31. }  

ASP.NET

For certifications

  1. public PartialViewResult CertificationsPartial(CertificationVM certification)  
  2. {  
  3.     List<SelectListItem> certificationLevel = new List<SelectListItem>()  
  4.     {  
  5.         new SelectListItem { Text = "Beginner", Value = "Beginner", Selected = true},  
  6.         new SelectListItem { Text = "Intermediate", Value = "Intermediate"},  
  7.         new SelectListItem { Text = "Advanced", Value = "Advanced"}  
  8.     };  
  9.   
  10.     certification.ListOfLevel = certificationLevel;  
  11.   
  12.     return PartialView("~/Views/Shared/_MyCertifications.cshtml", certification);  
  13. }  
  14.   
  15. public ActionResult AddCertification(CertificationVM certification)  
  16. {  
  17.     int idPer = (int)Session["IdSelected"];  
  18.     string msg = string.Empty;  
  19.   
  20.     //Creating Mapping  
  21.     Mapper.Initialize(cfg => cfg.CreateMap<CertificationVM, Certification>());  
  22.     Certification certificationEntity = Mapper.Map<Certification>(certification);  
  23.   
  24.     if (_resumeRepository.AddCertification(certificationEntity, idPer))  
  25.     {  
  26.         msg = "Certification added successfully";  
  27.     }  
  28.     else  
  29.     {  
  30.         msg = "something Wrong";  
  31.     }  
  32.   
  33.     return Json(new { data = msg }, JsonRequestBehavior.AllowGet);  
  34. }  

ASP.NET

For languages

  1. public PartialViewResult LanguagePartial(LanguageVM language)  
  2. {  
  3.     List<SelectListItem> languageLevel = new List<SelectListItem>()  
  4.     {  
  5.         new SelectListItem { Text = "Elementary Proficiency", Value = "Elementary Proficiency", Selected = true},  
  6.         new SelectListItem { Text = "LimitedWorking Proficiency", Value = "LimitedWorking Proficiency"},  
  7.         new SelectListItem { Text = "Professional working Proficiency", Value = "Professional working Proficiency"},  
  8.         new SelectListItem { Text = "Full Professional Proficiency", Value = "Full Professional Proficiency"},  
  9.         new SelectListItem { Text = "Native Or Bilingual Proficiency", Value = "Native Or Bilingual Proficiency"}  
  10.     };  
  11.   
  12.     language.ListOfProficiency = languageLevel;  
  13.   
  14.     return PartialView("~/Views/Shared/_MyLanguage.cshtml", language);  
  15. }  
  16.   
  17. public ActionResult AddLanguage(LanguageVM language)  
  18. {  
  19.     int idPer = (int)Session["IdSelected"];  
  20.     string msg = string.Empty;  
  21.   
  22.     //Creating Mapping  
  23.     Mapper.Initialize(cfg => cfg.CreateMap<LanguageVM, Language>());  
  24.     Language languageEntity = Mapper.Map<Language>(language);  
  25.   
  26.     if (_resumeRepository.AddLanguage(languageEntity, idPer))  
  27.     {  
  28.         msg = "Language added successfully";  
  29.     }  
  30.     else  
  31.     {  
  32.         msg = "something Wrong";  
  33.     }  
  34.   
  35.     return Json(new { data = msg }, JsonRequestBehavior.AllowGet);  
  36. }     

ASP.NET

To generate our resume, we are going to add the following actions.

  1. public ActionResult CV()  
  2. {  
  3.     return View();  
  4. }  

GetPersonnalInfoPartial

  1. public PartialViewResult GetPersonnalInfoPartial()  
  2. {  
  3.     int idPer = (int)Session["IdSelected"];  
  4.     Person person = _resumeRepository.GetPersonnalInfo(idPer);  
  5.   
  6.     //Creating Mapping  
  7.     Mapper.Initialize(cfg => cfg.CreateMap<Person, PersonVM>());  
  8.     PersonVM personVM = Mapper.Map<PersonVM>(person);  
  9.   
  10.     return PartialView("~/Views/Shared/_MyPersonnalInfo.cshtml", personVM);  
  11. }  

GetEducationCVPartial

  1. public PartialViewResult GetEducationCVPartial()  
  2. {  
  3.     int idPer = (int)Session["IdSelected"];  
  4.   
  5.     //Creating Mapping  
  6.     Mapper.Initialize(cfg => cfg.CreateMap<Education, EducationVM>());  
  7.     IQueryable<EducationVM> educationList = _resumeRepository.GetEducationById(idPer).ProjectTo<EducationVM>().AsQueryable();  
  8.   
  9.     return PartialView("~/Views/Shared/_MyEducationCV.cshtml", educationList);  
  10. }  

WorkExperienceCVPartial

  1. public PartialViewResult WorkExperienceCVPartial()  
  2. {  
  3.     int idPer = (int)Session["IdSelected"];  
  4.   
  5.     //Creating Mapping  
  6.     Mapper.Initialize(cfg => cfg.CreateMap<WorkExperience, WorkExperienceVM>());  
  7.     IQueryable<WorkExperienceVM> workExperienceList = _resumeRepository.GetWorkExperienceById(idPer).ProjectTo<WorkExperienceVM>().AsQueryable();  
  8.   
  9.   
  10.     return PartialView("~/Views/Shared/_WorkExperienceCV.cshtml", workExperienceList);  
  11. }  

SkillsCVPartial

  1. public PartialViewResult SkillsCVPartial()  
  2. {  
  3.     int idPer = (int)Session["IdSelected"];  
  4.   
  5.     //Creating Mapping  
  6.     Mapper.Initialize(cfg => cfg.CreateMap<Skill, SkillsVM>());  
  7.     IQueryable<SkillsVM> skillsList = _resumeRepository.GetSkillsById(idPer).ProjectTo<SkillsVM>().AsQueryable();  
  8.   
  9.   
  10.     return PartialView("~/Views/Shared/_MySkillsCV.cshtml", skillsList);  
  11. }  

CertificationsCVPartial

  1. public PartialViewResult CertificationsCVPartial()  
  2. {  
  3.     int idPer = (int)Session["IdSelected"];  
  4.   
  5.     //Creating Mapping  
  6.     Mapper.Initialize(cfg => cfg.CreateMap<Certification, CertificationVM>());  
  7.     IQueryable<CertificationVM> certificationList = _resumeRepository.GetCertificationsById(idPer).ProjectTo<CertificationVM>().AsQueryable();  
  8.   
  9.   
  10.     return PartialView("~/Views/Shared/_MyCertificationCV.cshtml", certificationList);  
  11. }  

LanguageCVPartial

  1. public PartialViewResult LanguageCVPartial()  
  2. {  
  3.     int idPer = (int)Session["IdSelected"];  
  4.   
  5.     //Creating Mapping  
  6.     Mapper.Initialize(cfg => cfg.CreateMap<Language, LanguageVM>());  
  7.     IQueryable<LanguageVM> languageList = _resumeRepository.GetLanguageById(idPer).ProjectTo<LanguageVM>().AsQueryable();  
  8.   
  9.   
  10.     return PartialView("~/Views/Shared/_MyLanguageCV.cshtml", languageList);  
  11. }  

That’s all. Please send your feedback and queries in the comments box.


Similar Articles