public async Task <IActionResult> GetCourseProgress(string progressId) { var result = await progressRepository.GetAsync(progressId); if (result == null) { return(NotFound($"Invalid progressId = {progressId}")); } var userId = result.UserId; if (!IdIsValid(userId)) { return(Forbid($"The user has no rights or the id = {userId} is invalid")); } return(Ok(result)); }
public async Task <IResult> UpdateAsync(ProgressModel model) { var validation = await new UpdateProgressModelValidator().ValidateAsync(model); if (validation.Failed) { return(Result.Fail(validation.Message)); } var Progress = await _ProgressRepository.GetAsync(model.Id); if (Progress == default) { return(Result.Success()); } Progress.ChangeWeight(model.Weight); await _ProgressRepository.UpdateWeightAsync(Progress); await _unitOfWork.SaveChangesAsync(); return(Result.Success()); }