public ActionResult Edit(int id, [Bind("JobListingId, CompanyId, CategoryId,Title,Type,Position,Region,Location,Description,IsActive,WorkExperience,Education,Skills,OtherNotes")] EditJobListingWithTemplateViewModel editJobListingWithTemplateViewModel)
        {
            JobListing jobListingFromDb        = _jobListingsRepository.GetJobListingById(id);
            int        userIdCurrentlyLoggedIn = Int32.Parse(User.Claims.FirstOrDefault(uc => uc.Type == ClaimTypes.NameIdentifier).Value);

            if (!_jobListingsRepository.isAllowedToModifyJobListing(userIdCurrentlyLoggedIn, jobListingFromDb.CompanyId))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                jobListingFromDb.Location    = editJobListingWithTemplateViewModel.Location;
                jobListingFromDb.Position    = editJobListingWithTemplateViewModel.Position;
                jobListingFromDb.Region      = editJobListingWithTemplateViewModel.Region;
                jobListingFromDb.Title       = editJobListingWithTemplateViewModel.Title;
                jobListingFromDb.Type        = editJobListingWithTemplateViewModel.Type;
                jobListingFromDb.Description = editJobListingWithTemplateViewModel.Description;
                jobListingFromDb.CategoryId  = editJobListingWithTemplateViewModel.CategoryId;
                jobListingFromDb.CompanyId   = editJobListingWithTemplateViewModel.CompanyId;
                jobListingFromDb.IsActive    = Convert.ToByte(editJobListingWithTemplateViewModel.IsActive);

                if (!editJobListingWithTemplateViewModel.IsActive)
                {
                    jobListingFromDb.JobListingClosedAt = DateTime.Now;
                }

                _jobListingsRepository.EditJobListing(jobListingFromDb);

                Template templateFromDb = _templatesRepository.GetTemplateByJobId(id);

                templateFromDb.WorkExperience    = Convert.ToByte(editJobListingWithTemplateViewModel.WorkExperience);
                templateFromDb.Skills            = Convert.ToByte(editJobListingWithTemplateViewModel.Skills);
                templateFromDb.Education         = Convert.ToByte(editJobListingWithTemplateViewModel.Education);
                templateFromDb.OtherNotes        = Convert.ToByte(editJobListingWithTemplateViewModel.OtherNotes);
                templateFromDb.JobListingId      = id;
                templateFromDb.UserId            = userIdCurrentlyLoggedIn;
                templateFromDb.TemplateUpdatedAt = DateTime.Now;
                _templatesRepository.EditTemplate(templateFromDb);

                ViewBag.SelectedNav = "Dashboard";
                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.SelectedNav = "Dashboard";
            return(View(editJobListingWithTemplateViewModel));
        }