public async Task <EntityDto <Guid> > CreateTextComment(CreateTextCommentInput input) { var currentUser = await GetCurrentUserAsync(); Comment textComment = null; if (input.ActivityId.HasValue) { var activity = await _activityManager.GetAsync(input.ActivityId.Value); textComment = await _commentManager.CreateAsync(TextComment.Create(input.Content, activity, currentUser)); } else if (input.ActivityTemplateId.HasValue) { var activityTemplate = await _activityTemplateManager.GetAsync(input.ActivityTemplateId.Value); textComment = await _commentManager.CreateAsync(TextComment.Create(input.Content, activityTemplate, currentUser)); } else if (input.ActivityPlanId.HasValue) { var activityPlan = await _activityPlanManager.GetAsync(input.ActivityPlanId.Value); textComment = await _commentManager.CreateAsync(TextComment.Create(input.Content, activityPlan, currentUser)); } else { throw new UserFriendlyException("Please provide either abstractActivityId or activityPlanId."); } return(new EntityDto <Guid>(textComment.Id)); }
public async Task <EntityDto <long> > CreateTextDescription(CreateTextDescriptionInput input) { var currentUserId = GetCurrentUserId(); Description textDescription; if (input.ActivityId.HasValue) { var activity = await _activityManager.GetAsync(input.ActivityId.Value); textDescription = await _descriptionManager.CreateAsync(TextDescription.Create(input.Text, activity, currentUserId)); } else if (input.ActivityTemplateId.HasValue) { var activityTemplate = await _activityTemplateManager.GetAsync(input.ActivityTemplateId.Value); textDescription = await _descriptionManager.CreateAsync(TextDescription.Create(input.Text, activityTemplate, currentUserId)); } else if (input.ActivityPlanId.HasValue) { var activityPlan = await _activityPlanManager.GetAsync(input.ActivityPlanId.Value); textDescription = await _descriptionManager.CreateAsync(TextDescription.Create(input.Text, activityPlan, currentUserId)); } else { throw new UserFriendlyException(""); } return(new EntityDto <long>(textDescription.Id)); }
public async Task UpdateActivity(UpdateActivityInput input) { var currentUserId = GetCurrentUserId(); var activity = await _activityManager.GetAsync(input.Id); var location = input.LocationId.HasValue ? await _locationManager.GetLocationAsync(input.LocationId.Value) : null; var tags = await _tagManager.GetTags(input.TagTexts); _activityManager.EditActivity(activity, input.Name, input.StartTime, input.EndTime, location, tags, currentUserId); _activityManager.EditDescriptions(activity, input.DescriptionIds, currentUserId); }
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)); }
public async Task <CreateActivityInvitationsOutput> CreateActivityInvitations(CreateActivityInvitationsInput input) { var currentUser = await GetCurrentUserAsync(); var invitees = await _userRepository.GetAllListAsync(user => input.InviteeIds.Contains(user.Id)); var activity = await _activityManager.GetAsync(input.ActivityId); var invitations = new List <ActivityInvitation>(); foreach (var invitee in invitees) { var invitation = await _activityInvitationManager.CreateAsync(ActivityInvitation.Create(invitee, currentUser, activity, input.Content, _activityInvitationPolicy)); invitations.Add(invitation); } return(new CreateActivityInvitationsOutput { InvitedUserIds = invitations.Select(i => i.InviteeId).ToArray() }); }