public PartialViewResult Competency(int id) { var manpower = manpowerService.GetDealerManpower(id); var competencies = competencyProfileMapService.FindCompetencyProfileMaps(x => x.DealerManpowerId == manpower.Id); var model = new CompetencyProfileViewModel { Competencies = competencies.Any() ?competencies.Select(x => new CompetencyProfileModel { Id = x.Id, Competency = x.Competency.Name, ComptencyId = x.CompetencyId, Score = x.Score }) : masterService.FindCompetencies(x => x.Designation.ToLower() == manpower.Type.ToLower()).Select(x => new CompetencyProfileModel { Id = 0, Competency = x.Name, ComptencyId = x.Id, Score = 0 }), ProfileId = id }; return PartialView("CompetencyPartial", model); }
public void Competency(CompetencyProfileViewModel model) { if (!model.Competencies.Any()) { return; } var competencies = model.Competencies.Select(CompetencyProfileModel.ToDomainModel); foreach (var comp in competencies) { comp.DealerManpowerId = model.ProfileId; if (comp.Id > 0) { competencyProfileMapService.UpdateCompetencyProfileMap(comp); } else { competencyProfileMapService.AddCompetencyProfileMap(new[] { comp }); } } }