예제 #1
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);
        }
예제 #2
0
 public async Task AddAsync(AppModel.User user)
 {
     this.AddUser(user);
     await this._unitOfWork.SaveChangesAsync();
 }
예제 #3
0
        public async Task <ActionResult> Create(AppModel.User user)
        {
            await this._userService.AddAsync(user);

            return(RedirectToAction("Index"));
        }