public async Task <EntityDto <long> > CreateRating(CreateRatingInput input) { var currentUser = await GetCurrentUserAsync(); Rating rating = null; if (input.ActivityId.HasValue) { var activity = await _activityManager.GetAsync(input.ActivityId.Value); rating = await _ratingManager.CreateAsync(input.RatingStatus, activity, currentUser); } else if (input.ActivityPlanId.HasValue) { var activityPlan = await _activityPlanManager.GetAsync(input.ActivityPlanId.Value); rating = await _ratingManager.CreateAsync(input.RatingStatus, activityPlan, currentUser); } else if (input.ActivityTemplateId.HasValue) { var activityTemplate = await _activityTemplateManager.GetAsync(input.ActivityTemplateId.Value); rating = await _ratingManager.CreateAsync(input.RatingStatus, activityTemplate, currentUser); } else { throw new UserFriendlyException("Please provide either activityId or activityPlanId or activityTemplateId."); } return(new EntityDto <long>(rating.Id)); }