コード例 #1
0
ファイル: HomeController.cs プロジェクト: jasonds/tracker
 private UserViewModel Map(DomainModel.User user)
 {
     return(new UserViewModel
     {
         Id = user.Id,
         Name = $"{user.FirstName} {user.LastName}",
         Location = user.Location,
         Status = user.Status,
         IsBench = user.IsBench,
         LastUpdatedUtc = user.LastUpdatedUtc
     });
 }
コード例 #2
0
        private void AddUser(AppModel.User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            if (string.IsNullOrWhiteSpace(user.FirstName) ||
                string.IsNullOrWhiteSpace(user.LastName))
            {
                throw new InvalidDataException("First and Last Name are Required");
            }

            DomainModel.User domainUser = new DomainModel.User(Guid.NewGuid());
            domainUser.FirstName      = user.FirstName;
            domainUser.LastName       = user.LastName;
            domainUser.Location       = user.Location;
            domainUser.Status         = user.Status;
            domainUser.IsBench        = user.IsBench;
            domainUser.LastUpdatedUtc = DateTime.UtcNow;

            this._userRepository.Add(domainUser);
        }