Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
 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());
 }
Esempio n. 4
0
 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));
 }
Esempio n. 5
0
 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));
 }
Esempio n. 6
0
 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));
 }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
 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");
     }
 }
Esempio n. 9
0
        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");
            }
        }