Exemplo n.º 1
0
        public void AddUser(UserDto model, string operatedBy)
        {
            if (string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.Mobile))
            {
                throw new AppServiceException("User name and mobile can not be null.");
            }

            var user = _userRepository.GetFiltered(o => o.UserName == model.UserName).FirstOrDefault();

            if (user != null)
            {
                throw new AppServiceException("User name already exists in the db.");
            }

            user = UserFactory.CreateInstance(model.UserName, model.Mobile, model.Email, model.Password, model.NickName, operatedBy);
            _userRepository.Add(user);
            _dbUnitOfWork.Commit();
        }