Ejemplo n.º 1
0
        public UserRegistrationKeyEntity Create(string key, int uses)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new EntityValidationException("Key must not be empty.");
            }

            if (_userRegistrationKeyRepository.Exists(key))
            {
                throw new EntityAlreadyExistsException("A registration key with this key value already exists!");
            }

            if (uses < 1)
            {
                throw new EntityValidationException("Must have at least once use!");
            }

            var entity = new UserRegistrationKeyEntity()
            {
                Active        = true,
                Key           = key,
                UsesRemaining = uses
            };

            _userRegistrationKeyRepository.Create(entity);
            return(entity);
        }
Ejemplo n.º 2
0
 public void Update(UserRegistrationKeyEntity registrationKey)
 {
     _db.UserRegistrationKeys.Attach(registrationKey);
     _db.SaveChanges();
 }
Ejemplo n.º 3
0
 public void Create(UserRegistrationKeyEntity registrationKey)
 {
     _db.UserRegistrationKeys.Add(registrationKey);
     _db.SaveChanges();
 }