public void Create_inputDtoAddActivity_AreNotSame()
        {
            var input = new InputDtoAddActivity("name", 1, 1, 1);
            var unit  = new Unit("type");

            unit.Id = 1;
            var category = new Category("name");

            category.Id = 1;

            var activityFromDto = new Activity(input.Name, input.Repetitions, unit, category);
            var activityInDb    = new Activity(input.Name, input.Repetitions, unit, category);

            activityInDb.Id = 1;

            _activityFactory.CreateFromValues(input.Name, input.Repetitions, unit, category)
            .Returns(activityFromDto);
            _unitRepository.GetById(input.UnitId).Returns(unit);
            _categoryRepository.GetById(input.CategoryId).Returns(category);
            _activityRepository.Create(activityFromDto).Returns(activityInDb);

            OutputDtoAddActivity expected = new OutputDtoAddActivity(1, "other" + input.Name, input.Repetitions, category.Name, unit.Type);

            var res = _activityService.Create(input);

            Assert.AreNotEqual(expected, res);
        }
        /*
         * Créer une activité
         */
        public OutputDtoAddActivity Create(InputDtoAddActivity inputDtoAddActivity)
        {
            var unit     = _unitRepository.GetById(inputDtoAddActivity.UnitId);
            var category = _categoryRepository.GetById(inputDtoAddActivity.CategoryId);


            var activityFromDto = _activityFactory.CreateFromValues(inputDtoAddActivity.Name,
                                                                    inputDtoAddActivity.Repetitions, unit, category);
            var activityInDb = _activityRepository.Create(activityFromDto);

            return(new OutputDtoAddActivity
            {
                Id = activityInDb.Id,
                CategoryName = activityInDb.Category.Name,
                Name = activityInDb.Name,
                Repetitions = activityInDb.Repetitions,
                UnitType = activityInDb.Unit.Type
            });
        }
 public ActionResult <OutputDtoAddActivity> Post([FromBody] InputDtoAddActivity inputDtoAddActivity)
 {
     return(Ok(_activityService.Create(inputDtoAddActivity)));
 }