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); }
public void Update(UserRegistrationKeyEntity registrationKey) { _db.UserRegistrationKeys.Attach(registrationKey); _db.SaveChanges(); }
public void Create(UserRegistrationKeyEntity registrationKey) { _db.UserRegistrationKeys.Add(registrationKey); _db.SaveChanges(); }