private List <CategoryStatusDto> MapCategoryStatuses(string userId) { CategoryData categoryData = _categoriesDAL.GetCategoryData(userId); var categories = Enum.GetValues(typeof(Category)).Cast <Category>(); var categoryDataDictionary = categoryData.GetType().GetProperties().ToDictionary(prop => prop.Name, prop => prop.GetValue(categoryData, null)); List <CategoryStatusDto> categoryStatusDtos = new List <CategoryStatusDto>(); foreach (var category in categories) { string categoryName = Enum.GetName(typeof(Category), category); bool isActive = (bool)categoryDataDictionary[categoryName]; CategoryStatusDto categoryStatus = new CategoryStatusDto() { CategoryName = categoryName, CategoryTypeId = category, IsActive = isActive, State = State.Unchanged }; categoryStatusDtos.Add(categoryStatus); } return(categoryStatusDtos); }