public AcceptInvitationStatus AcceptProjectInvitation(int invitationID) { ProjectInvitation invitation = ProjectInvitations.Get(invitationID); if (invitation == null) { return(AcceptInvitationStatus.NoSuchInvitation); } if (invitation.TargetUserID != UserContext.AccountID) { return(AcceptInvitationStatus.NotTarget); } if (invitation.Type == ProjectInvitationType.Manager) { invitation.TargetProject.Managers.Add(invitation.TargetUser); } else if (invitation.Type == ProjectInvitationType.Reader) { invitation.TargetProject.Readers.Add(invitation.TargetUser); } else if (invitation.Type == ProjectInvitationType.Owner) { invitation.TargetProject.OwnerUserID = invitation.TargetUserID; } ActivityService.ProjectInvitationAccepted(invitation.ID); ProjectRepository.Update(invitation.TargetProject); ProjectInvitations.Delete(invitation); return(AcceptInvitationStatus.Accepted); }
public DeleteInvitationStatus DeleteProjectInvitation(int invitationID) { ProjectInvitation invitation = ProjectInvitations.Get(invitationID); if (invitation == null) { return(DeleteInvitationStatus.NoSuchInvitation); } if (invitation.TargetProject.OwnerUserID != UserContext.AccountID) { return(DeleteInvitationStatus.NotOwner); } ActivityService.ProjectInvitationDeleted(invitation.ID); ProjectInvitations.Delete(invitation); return(DeleteInvitationStatus.Deleted); }