Ejemplo n.º 1
0
        private CreatureDetailsModel GetCreatureModel(Creature creature, CreatureDetailsModel vm)
        {
            vm.DifficultyItems         = _enumService.GetDifficulties();
            vm.ReefCompatabilityItems  = _enumService.GetReefCompatability();
            vm.SpecialRequirementItems = _enumService.GetSpecialRequirements();
            vm.TemperamentItems        = _enumService.GetTemperament();
            vm.TagList  = new Guid[0];
            vm.TagItems = new List <TagTypeViewModel>();

            var tagsByTagType = _tagRepository.FindAll().GroupBy(x => EnumHelper <TagType> .GetDisplayValue(x.TagType));

            foreach (var tagType in tagsByTagType)
            {
                var tagtypeModel = new TagTypeViewModel()
                {
                    Name = tagType.Key,
                    Tags = tagType.Select(x => x).ToList(),
                };
                vm.TagItems.Add(tagtypeModel);
            }

            if (creature != null)
            {
                if (creature.CreatureTags.Any())
                {
                    vm.TagList = new Guid[creature.CreatureTags.Count];
                }

                var index = 0;
                foreach (var creatureTag in creature.CreatureTags)
                {
                    vm.TagList[index] = creatureTag.TagId;
                    index++;
                }
            }

            return(vm);
        }
Ejemplo n.º 2
0
        private CreatureDetailsModel GetCreatureModel(Creature creature, CreatureDetailsModel vm)
        {
            var category = _categoryRepository.GetCategory(vm.CategoryId);

            vm.SubcategoryItems        = _subcategoryRepository.GetSubcategories(category.Id).ToList();
            vm.DifficultyItems         = _enumService.GetDifficulties();
            vm.ReefCompatabilityItems  = _enumService.GetReefCompatability();
            vm.SpecialRequirementItems = _enumService.GetSpecialRequirements();
            vm.TemperamentItems        = _enumService.GetTemperament();

            vm.TagItems = new List <TagTypeViewModel>();

            var tagsByTagType = _tagRepository.FindAll().GroupBy(x => EnumHelper <TagType> .GetDisplayValue(x.TagType)).ToList();

            foreach (var tagType in tagsByTagType)
            {
                var tagtypeModel = new TagTypeViewModel()
                {
                    Name = tagType.Key,
                    Tags = tagType.Select(x => x).ToList(),
                };
                vm.TagItems.Add(tagtypeModel);
            }

            if (vm.TagList == null)
            {
                vm.TagList = new Guid[0];

                if (creature != null && creature.CreatureTags.Any())
                {
                    vm.TagList = creature.CreatureTags.Select(x => x.TagId).ToArray();
                }
            }

            return(vm);
        }