private Clubs_EmailsDTO GetRelation(EmailDTO email) { email = email.Id == 0 ? DbEntityExistensChecker.TryGetExistingEmailFromDb(email) : email; return(ServiceLocator.ClubsEmailsService.FindBy( ceJunc => ceJunc.ClubId == Id && ceJunc.EmailId == email.Id) .First()); }
public void AddEmailToClub(UserDTO caller, EmailDTO email) { NullCheck.ThrowArgumentNullEx(caller, email); CheckPermission(caller); email = email.Id == 0 ? DbEntityExistensChecker.TryGetExistingEmailFromDb(email) ?? DbEntityAdder.AddEmailToDb(email) : email; SaveRelationToDb(CreateRelation(email)); }
private Clubs_PhoneNumbersDTO GetRelation(PhoneNumberDTO phoneNumber) { phoneNumber = phoneNumber.Id == 0 ? DbEntityExistensChecker.TryGetExistingPhoneNumberFromDb(phoneNumber) : phoneNumber; return(ServiceLocator.ClubsPhoneNumbersService.FindBy( cpJunc => cpJunc.ClubId == Id && cpJunc.PhoneNumberId == phoneNumber.Id) .First()); }
public void AddRoleRelation(UserDTO caller, UserDTO user, Role role) { NullCheck.ThrowArgumentNullEx(user); _target.CheckPermission(caller); user = user.Id == 0 ? DbEntityExistensChecker.TryGetExistingUserFromDb(user) ?? DbEntityAdder.AddUserToDb(user) : user; AddRoleRelationToDb(CreateRoleRelation(user, role)); }
public void AddPhoneNumberToClub(UserDTO caller, PhoneNumberDTO phoneNumber) { NullCheck.ThrowArgumentNullEx(caller, phoneNumber); CheckPermission(caller); phoneNumber = phoneNumber.Id == 0 ? DbEntityExistensChecker.TryGetExistingPhoneNumberFromDb(phoneNumber) ?? DbEntityAdder.AddPhoneNumberToDb(phoneNumber) : phoneNumber; SaveRelationToDb(CreateRelation(phoneNumber)); }
public void AddUserToEntry(UserDTO caller, UserDTO userToAdd) { NullCheck.ThrowArgumentNullEx(userToAdd); CheckPermissionAllowSelfHandling(caller, userToAdd); userToAdd = userToAdd.Id == 0 ? DbEntityExistensChecker.TryGetExistingUserFromDb(userToAdd) ?? DbEntityAdder.AddUserToDb(userToAdd) : userToAdd; AddRelationToDb(GetRelation(userToAdd)); }
public void AddRoleRelation(UserDTO caller, UserDTO user, PhoneNumberDTO phoneNumber, EmailDTO email, Role role) { NullCheck.ThrowArgumentNullEx(user, phoneNumber, email); _target.CheckPermission(caller); user = user.Id == 0 ? DbEntityExistensChecker.TryGetExistingUserFromDb(user) ?? DbEntityAdder.AddUserToDb(user) : user; phoneNumber = phoneNumber.Id == 0 ? DbEntityExistensChecker.TryGetExistingPhoneNumberFromDb(phoneNumber) ?? DbEntityAdder.AddPhoneNumberToDb(phoneNumber) : phoneNumber; email = email.Id == 0 ? DbEntityExistensChecker.TryGetExistingEmailFromDb(email) ?? DbEntityAdder.AddEmailToDb(email) : email; AddRoleRelationToDb(CreateRoleRelation(user, phoneNumber, email, role)); }
public void AddUserToSocialEvent(UserDTO caller, UserDTO userToAdd, int numberOfFriends) { NullCheck.ThrowArgumentNullEx(caller, userToAdd); CheckPermissionAllowSelfHandling(caller, userToAdd); if (userToAdd.Permissions.GetAttendancePermissions <SocialEventDTO>().Any(sePer => sePer.Id == Id)) { userToAdd = userToAdd.Id == 0 ? DbEntityExistensChecker.TryGetExistingUserFromDb(userToAdd) ?? DbEntityAdder.AddUserToDb(userToAdd) : userToAdd; AddRelationToDb(CreateAttendancesRelation(userToAdd, numberOfFriends)); } else { throw new ArgumentException($"User: {userToAdd.Login} do not have permission to attend this socialevent"); } }
public void AddUserToTeam(UserDTO caller, UserDTO userToAdd) { NullCheck.ThrowArgumentNullEx(caller, userToAdd); CheckPermissionAllowSelfHandling(caller, userToAdd); if (userToAdd.Permissions.GetTeamParticipationPermissions().Any(t => t.Id == Id)) { userToAdd = userToAdd.Id == 0 ? DbEntityExistensChecker.TryGetExistingUserFromDb(userToAdd) ?? DbEntityAdder.AddUserToDb(userToAdd) : userToAdd; SaveRelationToDb(CreateRelation(userToAdd)); } else { throw new ArgumentException($"User: {userToAdd.Login} cannot be added to this team." + $"Make sure that the user is affiliated with an entry that holds this team"); } }