Example #1
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());
 }
Example #2
0
        public UserDTO(IUser user)
        {
            if (user.Id < 0)
            {
                throw new ArgumentOutOfRangeException($"{nameof(user.Id)} cannot be less than 0.");
            }
            AddressDTO     address     = new AddressDTO(user.Address);
            PhoneNumberDTO phoneNumber = new PhoneNumberDTO(user.PhoneNumber);

            ValidateInParameters(user.Login, user.Password, user.FirstName, user.LastName, user.PhoneNumber.Id, user.Address.Id, user.ICE_Name, user.ICE_PhoneNumber);

            Id              = user.Id;
            Login           = user.Login;
            Password        = user.Password;
            FirstName       = user.FirstName;
            LastName        = user.LastName;
            ICE_Name        = user.ICE_Name;
            ICE_PhoneNumber = user.ICE_PhoneNumber;
            PhoneNumberId   = user.PhoneNumber.Id;
            AddressId       = user.Address.Id;
            Address         = address;
            PhoneNumber     = phoneNumber;

            Active  = user.Active;
            sa_Info = user.sa_Info;
        }
Example #3
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));
 }
Example #4
0
 private Clubs_PhoneNumbersDTO CreateRelation(PhoneNumberDTO phoneNumber)
 {
     return(new Clubs_PhoneNumbersDTO()
     {
         ClubId = Id,
         PhoneNumberId = phoneNumber.Id
     });
 }
Example #5
0
 public void RemovePhoneNumberFromClub(UserDTO caller, PhoneNumberDTO phoneNumber)
 {
     NullCheck.ThrowArgumentNullEx(caller, phoneNumber);
     CheckPermission(caller);
     RemoveRelationFromDb(GetRelation(phoneNumber));
 }