public async Task <IHttpActionResult> UpdateFeedbackAsync
            ([FromBody, CustomizeValidator(RuleSet = "UpdateFeedback, default")] Feedback feedback)
        {
            if (feedback is null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _feedbackBase.UpdateFeedbackAsync(feedback);

            return(result.IsError ? BadRequest(result.Message) : (IHttpActionResult)Ok(result.Data));
        }
Exemple #2
0
        public async Task UpdateFeedbackAsync_Test()
        {
            var      feedbackDB  = _listFeedbackDB.FirstOrDefault();
            Feedback whasUpdated = _mapper.Map <Feedback>(feedbackDB);

            _mockUnitRepo.Setup(_ => _.Feedbacks.Update(feedbackDB))
            .Callback(() => { feedbackDB.Text = "Updated"; });

            _mockUnitRepo.Setup(_ => _.SaveAsync());

            var result = await _service.UpdateFeedbackAsync(whasUpdated);

            result.IsError.Should().BeFalse();
            result.Data.Should().BeEquivalentTo(whasUpdated);
        }