Esempio n. 1
0
 public async Task Update(string id, [FromBody] TestDto test)
 {
     test.Code = id;
     var request = new UpdateTestRequest
     {
         Test = test
     };
     await _mediator.ExecuteAsync(request).ConfigureAwait(false);
 }
Esempio n. 2
0
        public async Task <IActionResult> Update([FromRoute] Guid testID, [FromBody] UpdateTestRequest testRequest)
        {
            var userOwnsTest = await _testService.UserOwnsTestAsync(testID, HttpContext.GetUserId());

            if (!userOwnsTest)
            {
                return(BadRequest(new { error = "You do not own this test" }));
            }

            var test = await _testService.GetTestByIDAsync(testID);

            test.Text = testRequest.Text;

            var updated = await _testService.UpdateTestAsync(test);

            if (updated)
            {
                return(Ok(test));
            }

            return(NotFound());
        }