public void AddSubject(Name subjectName) { if (Subjects.Any(s => s.Name == subjectName)) { throw DomainException.With($"SubjectName '{subjectName}' already exists in this unit."); } _subjects.Add(new Subject(subjectName)); }
public void AddSmsBalance(int amount) { if (amount <= 0) { throw DomainException.With("Invalid addition amount :{0}", amount); } SmsBalance += amount; }
public Subject RemoveSubject(int id) { for (var i = 0; i < _subjects.Count; i++) { if (_subjects[i].Id == id) { var subject = _subjects[i]; _subjects.Remove(subject); return(subject); } } throw DomainException.With("Subject id {0} does not exist in {1} - {2} unit", id, Id, Name); }
public void DeductSmsBalance(int amount) { if (amount <= 0) { throw DomainException.With("Invalid deduction amount :{0}", amount); } if (SmsBalance - amount < 0) { throw DomainException.With( "Insufficient SMS credit.Current credit :{0}, DeductAmount :{1} ", SmsBalance, amount); } SmsBalance -= amount; }