public Trait mapTraitDtoToTrait(TraitDto traitDto)
        {
            Trait trait = new Trait();

            trait.Description = traitDto.Description;
            trait.Name        = traitDto.Name;
            trait.Id          = traitDto.Id;
            return(trait);
        }
        public TraitDto mapTraitToTraitDto(Trait trait)
        {
            TraitDto traitDto = new TraitDto();

            traitDto.Description = trait.Description;
            traitDto.Name        = trait.Name;
            traitDto.Id          = trait.Id;
            return(traitDto);
        }
Esempio n. 3
0
        public IActionResult UpdateTrait([FromBody] TraitDto updatedTrait)
        {
            var traitToUpdate = GetTrait(updatedTrait.Id);

            if (string.IsNullOrEmpty(updatedTrait.Title))
            {
                return(BadRequest("Title missing"));
            }

            traitToUpdate.Title = updatedTrait.Title;
            _traitsRepository.Update(traitToUpdate);
            return(Ok("Trait updated successfully"));
        }
Esempio n. 4
0
        public IActionResult DeleteTrait([FromBody] TraitDto deletedTrait)
        {
            var traitToDelete = GetTrait(deletedTrait.Id);

            if (traitToDelete == null)
            {
                return(NotFound("Trait does not exist in the database"));
            }
            else
            {
                _traitsRepository.Delete(traitToDelete);
                return(Ok("Trait has been deleted"));
            }
        }
Esempio n. 5
0
        public IActionResult AddTrait([FromBody] TraitDto traitData)
        {
            if (string.IsNullOrEmpty(traitData.Title))
            {
                return(BadRequest("Title missing"));
            }

            Trait newTrait = new Trait
            {
                Title = traitData.Title,
            };

            _traitsRepository.Add(newTrait);

            return(Ok("Trait added successfully"));
        }