示例#1
0
        public async Task <IActionResult> CancelReview(Guid id)
        {
            var currentTerm = await _usosService.GetCurrentAcademicYear();

            var deadline = await _settingsService.GetDeadline(_userContext.GetCredentials());

            if (!_reviewService.ReviewExists(id))
            {
                return(new NotFoundObjectResult("Nie ma recenzji o podanym identyfikatorze."));
            }

            var review = await _reviewService.GetAsync(id);

            if (!review.IsConfirmed)
            {
                return(new BadRequestObjectResult("Nie można anulować niezatwierdzonej recenzji."));
            }

            if (DateTime.Now > deadline || currentTerm.Id != review.Thesis.TermId)
            {
                return(new BadRequestObjectResult("Nie można anulować recenzji po upływie terminu końcowego."));
            }

            await _reviewService.CancelReviewConfirmation(id);

            if (!string.IsNullOrEmpty(review.Thesis.Grade))
            {
                await _thesisService.CancelGrade(review.Thesis.Guid);
            }

            return(new OkResult());
        }