Пример #1
0
        public async Task <IActionResult> CancelGrade(Guid id)
        {
            var currentTerm = await _usosService.GetCurrentAcademicYear();

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

            if (!_thesisService.ThesisExists(id))
            {
                return(new NotFoundObjectResult("Nie ma pracy o podanym identyfikatorze."));
            }

            var hasGrade = await _thesisService.HasGrade(id);

            if (!hasGrade)
            {
                return(new BadRequestObjectResult("Praca nie posiada oceny."));
            }

            var thesisTermId = await _thesisService.GetThesisTermId(id);

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

            await _thesisService.CancelGrade(id);

            return(new OkResult());
        }
Пример #2
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());
        }