コード例 #1
0
        public async Task UpdateShouldUpdateFields()
        {
            var user = new Traininglog {
                Id = _random.Next(), UserId = _currentUser.Id
            };

            _traininglogList.Add(user);

            var model = new UpdateTrainingLogModel
            {
                Date        = DateTime.Now,
                Description = _random.Next().ToString(),
                Rating      = _random.Next(),
                Comment     = _random.Next().ToString()
            };

            var result = await _query.Update(user.Id, model);

            result.Should().Be(user);
            result.Description.Should().Be(model.Description);
            result.Comment.Should().Be(model.Comment);
            result.Date.Should().BeCloseTo(model.Date);
            result.Rating.Should().Be(model.Rating);

            _uow.Verify(x => x.CommitAsync());
        }
コード例 #2
0
        public async Task <TrainingLogModel> Put(int id, [FromBody] UpdateTrainingLogModel requestModel)
        {
            var item = await _query.Update(id, requestModel);

            var model = _mapper.Map <TrainingLogModel>(item);

            return(model);
        }