private List <ProjectViewModel> MappingForProjectViewModel(List <ProjectViewModel> projectViewModels) { foreach (var item in projectViewModels) { //Adding progress values var progress = _progressRepository.GetProgressByProjectId(item.ProjectId); if (progress != null) { item.DesiredValue = progress.DesiredValue; item.ProgressValue = progress.Value; item.PercentageOfCompletion = Math.Round(progress.Value / progress.DesiredValue * 100, 2); } //Adding hashtag names to list var ids = item.HashtagIds is null ? null : Array.ConvertAll(item.HashtagIds.Split(","), int.Parse).ToList(); if (ids != null) { ids.Sort(); var hashtags = _hashtagRepository.GetHashtagsByIds(ids.First(), ids.Last()); if (hashtags != null) { foreach (var hashtagId in ids) { item.HashtagNames.Add(hashtags.Where(x => x.HashtagId == hashtagId).Select(x => x.Name).First()); } } } //Adding KindOfProject name item.KindOfProjectName = _kindOfProjectRepository.GetKindById(item.KindOfProjectId).Name; } return(projectViewModels); }
public KindOfProject Get(int id) { return(_kindOfProjectRepository.GetKindById(id)); }