public IActionResult UpdateCollective([FromBody] CollectiveDto collective)
        {
            if (collective == null)
            {
                return(NotFound());
            }

            var collectiveEntity = Mapper.Map <Collective>(collective);

            _repository.UpdateCollective(collectiveEntity);

            if (!_repository.Save())
            {
                throw new Exception("Update a collective failed on save.");
                // return StatusCode(500, "A problem happened with handling your request.");
            }

            var collectiveToReturn = Mapper.Map <CollectiveDto>(collectiveEntity);

            return(Ok(collectiveToReturn));
        }
        public IActionResult CreateCollective([FromBody] CollectiveDto collective)
        {
            if (collective == null)
            {
                return(BadRequest());
            }

            var collectiveEntity = Mapper.Map <Collective>(collective);

            _repository.AddCollective(collectiveEntity);

            if (!_repository.Save())
            {
                throw new Exception("Create a collective failed on save.");
                // return StatusCode(500, "A problem happened with handling your request.");
            }

            var collectiveToReturn = Mapper.Map <CollectiveDto>(collectiveEntity);

            return(CreatedAtRoute("GetCollective",
                                  new { id = collectiveToReturn.Id },
                                  collectiveToReturn));
        }