private void SetTechnicalEnvironment(ProfessionalExperience current, TechnicalEnvironmentViewModel tech) { var existing = string.IsNullOrEmpty(tech.Id) ? new TechnicalEnvironment { IsRelevant = tech.IsRelevant, Name = tech.Name, }: _techService.GetById(Guid.Parse(tech.Id)); if (tech.IsDeleted) { _techService.Delete(existing); } else { existing.IsRelevant = tech.IsRelevant; existing.Name = tech.Name; if (string.IsNullOrEmpty(tech.Id)) { current.TechnicalEnvironments.Add(existing); } } }
public KonsultantCreationModel toViewModel(Konsultant source) { if (source == null) { return(new KonsultantCreationModel()); } var result = new KonsultantCreationModel { Id = source.Id.ToString(), Name = source.Name, Surname = source.Surname, Function = source.Function, Availability = source.Availability.Date, }; foreach (var comp in source.Competences) { var current = new CompetenceViewModel { Id = comp.CompetenceId.ToString(), Name = comp.Competence?.Name, Rating = (int)comp.Rating, IsRelevant = comp.IsRelevant }; result.Competences.Add(current); result.Competences = result.Competences.OrderByDescending(x => x.Rating).ToList(); } foreach (var lang in source.Languages) { var current = new LanguageViewModel { Id = lang.LanguageId.ToString(), Name = lang.Language?.Name, Fluency = (int)lang.Fluency, IsRelevant = lang.IsRelevant, }; result.Languages.Add(current); } foreach (var edu in source.Educations) { var current = new EducationViewModel { Id = edu.EducationId.ToString(), Name = edu.Education?.Name, StartDate = edu.StartDate.Date, EndDate = edu.EndDate.Date, IsRelevant = edu.IsRelevant }; result.Educations.Add(current); } foreach (var cert in source.Certificates) { var current = new CertificateViewModel { Id = cert.CertificateId.ToString(), Name = cert.Certificate?.Name, Obtension = cert.Obtension, EndOfValidity = cert.EndOfValidity, IsRelevant = cert.IsRelevant }; result.Certificates.Add(current); } foreach (var exp in source.ProfessionalExperiences) { var curr = new ProfessionalExperienceViewModel { Id = exp.Id.ToString(), Position = exp.Position, Summary = exp.Summary, Customer = exp.Customer, StartDate = exp.StartDate.Date, EndDate = exp.EndDate.Date, IsRelevant = exp.IsRelevant }; foreach (var acc in exp.Accomplishments) { var accomplished = new AccomplishmentViewModel { Id = acc.Id.ToString(), Title = acc.Title, IsRelevant = acc.IsRelevant }; curr.Accomplishments.Add(accomplished); } ; foreach (var tech in exp.TechnicalEnvironments) { var technical = new TechnicalEnvironmentViewModel { Id = tech.Id.ToString(), Name = tech.Name, IsRelevant = tech.IsRelevant }; curr.TechnicalEnvironments.Add(technical); } ; result.ProfessionalExperiences.Add(curr); } foreach (var refer in source.ProfessionalReferences) { var current = new ProfessionalReferenceViewModel { Id = refer.Id.ToString(), Name = refer.Name, Surname = refer.Surname, Function = refer.Function, Mail = refer.Contacts?.Mail, Phone = refer.Contacts?.Phone }; result.ProfessionalReferences.Add(current); } return(result); }