public static TagTypeViewModel ToTagTypeViewModel(this TagType tagType)
        {
            if (Equals(tagType, null))
            {
                return(null);
            }

            var tagTypeViewModel = new TagTypeViewModel()
            {
                Description = tagType.Description,
                Id          = tagType.Id,
                Code        = tagType.Code,
                Active      = tagType.Active
            };

            if (tagType.Tags.Any())
            {
                foreach (var tag in tagType.Tags)
                {
                    tagTypeViewModel.Tags.Add(tag.TagToTagViewModel());
                }
            }

            return(tagTypeViewModel);
        }
示例#2
0
        // GET: TagType/Edit/5
        public ActionResult Edit(int id)
        {
            ViewBag.Action = "Edit";

            TagTypeViewModel tagTypeViewModel = Get(id);

            return(View("CreateOrEdit", tagTypeViewModel));
        }
示例#3
0
        public ActionResult Edit(TagTypeViewModel tagTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                BaseTagType tagType = Mapper.Map <TagTypeViewModel, BaseTagType>(tagTypeViewModel);
                _tagTypeRest.Put(tagType);
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(TagTypeViewModel tagTypeViewModel)
        {
            if (ModelState.IsValid)
            {
                BaseTagType tagType = Mapper.Map<TagTypeViewModel, BaseTagType>(tagTypeViewModel);
                _tagTypeRest.Put(tagType);
            }

            return RedirectToAction("Index");
        }
示例#5
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);
        }
        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);
        }
示例#7
0
 public ActionResult Delete(TagTypeViewModel tagTypeViewModel)
 {
     _tagTypeRest.Delete(tagTypeViewModel.Id);
     return(RedirectToAction("Index"));
 }
示例#8
0
        // GET: TagType/Delete/5
        public ActionResult Delete(int id)
        {
            TagTypeViewModel tagTypeViewModel = Get(id);

            return(View("Delete", tagTypeViewModel));
        }
 public ActionResult Delete(TagTypeViewModel tagTypeViewModel)
 {
     _tagTypeRest.Delete(tagTypeViewModel.Id);
     return RedirectToAction("Index");
 }