예제 #1
0
        public User(Psuser dao, ILocation defaultLocation) : this(dao.FirstName, dao.LastName)
        {
            Dao = dao ?? throw new ArgumentNullException(paramName: nameof(dao));

            if (defaultLocation.Dao.LocationId != dao.DefaultLocation.LocationId)
            {
                throw new InvalidOperationException("location inconsistent between dto and dao.");
            }

            FirstName       = dao.FirstName;
            LastName        = dao.LastName;
            AccountID       = dao.UserId;
            DefaultLocation = defaultLocation ?? throw new ArgumentNullException(paramName: nameof(defaultLocation));
        }
예제 #2
0
 public User(string firstName, string lastName, ILocation defaultLocation) : this(firstName, lastName)
 {
     DefaultLocation = defaultLocation ?? throw new ArgumentNullException(paramName: nameof(defaultLocation));
     Dao             = new Psuser
     {
         FirstName       = FirstName,
         LastName        = LastName,
         DefaultLocation = DefaultLocation.Dao
     };
     PSDBContextProvider.Current.UpdateAndSave(Dao);
     if (Dao.UserId == default)
     {
         throw new InvalidOperationException("could not register user.");
     }
     AccountID = Dao.UserId;
 }