public void Add(User user)
 {
     // check if users eMail or account name exist
     if (CheckIfEmailExist(user.Email) || CheckIfAccountnameExist(user.AccountName))
     {
         //return message user with this eMail or account name already exist
     }
     else
     {
         if (CheckIfFullNameExist(user.FirstName, user.LastName) && !user.DoubleUserIsOk)
         {
             User UserExist = _userRepo.FindByFullName(user.FirstName, user.LastName);
             //return message user exist with UserExist.username last name account name and email.
         }
         else //register user to ad
         {
             if (string.IsNullOrEmpty(user.AccountName) && user.DoubleUserIsOk)//external user
             {
                 //generate a accountName for external user
                 user.AccountName = GenerateNewAccountname(user.FirstName, user.LastName);
             }
             _uow.Users.Add(user);
             _uow.SaveChanges();
         }
     }
 }
 public void Add(User user)
 {
     //_userRepo.Add(user);
     //_uow.SaveChanges();
     _uow.Users.Add(user);
     _uow.SaveChanges();
 }
Esempio n. 3
0
        public void Add(User user)
        {
            try
            {
                //if (CheckIfEmailExist(user.Email) || CheckIfAccountnameExist(user.AccountName))
                //{
                //    //return FUNCTIONAL EXCEPTION message user with this eMail or account name already exist
                //}

                if (!CheckIfEmailExist(user.Email) || !CheckIfAccountnameExist(user.AccountName))
                {
                    if (string.IsNullOrEmpty(user.AccountName))    //external user
                    {
                        //generate a accountName for external user
                        user.AccountName = GenerateNewAccountname(user.FirstName.Trim(), user.LastName.Trim());
                    }
                    _uow.Users.Add(Mapping.MapUsertoUserDB(user));
                    _uow.SaveChanges();
                }
            }
            catch (Exception)
            {
                throw;
            }



            //// check if users eMail or account name exist
            //if (CheckIfEmailExist(user.Email) || CheckIfAccountnameExist(user.AccountName))
            //{
            //    //return message user with this eMail or account name already exist
            //}
            //else
            //{
            //    if (CheckIfFullNameExist(user.FirstName, user.LastName) && !user.DoubleUserIsOk)
            //    {
            //            User UserExist = _userRepo.FindByFullName(user.FirstName, user.LastName);
            //            //return message user exist with UserExist.username last name account name and email.
            //    }
            //    else //register user to ad
            //    {
            //        if (string.IsNullOrEmpty(user.AccountName))//external user
            //        {
            //            //generate a accountName for external user
            //           user.AccountName = GenerateNewAccountname(user.FirstName, user.LastName);
            //        }
            //        _uow.Users.Add(user);
            //        _uow.SaveChanges();
            //    }
            //}
        }
Esempio n. 4
0
 /// <summary>
 /// Test insert
 /// </summary>
 /// <param name="test">Test to insert</param>
 public void Add(Test test)
 {
     _unitOfWork.Repository <Test>().Add(test);
     _unitOfWork.SaveChanges();
 }
Esempio n. 5
0
 /// <summary>
 /// Course insert
 /// </summary>
 /// <param name="course">Course to insert</param>
 public void Add(Course course)
 {
     _unitOfWork.Repository <Course>().Add(course);
     _unitOfWork.SaveChanges();
 }
 /// <summary>
 /// DepartmentCourse insert
 /// </summary>
 /// <param name="departmentCourse">DepartmentCourse to insert</param>
 public void Add(DepartmentCourse departmentCourse)
 {
     _unitOfWork.Repository <DepartmentCourse>().Add(departmentCourse);
     _unitOfWork.SaveChanges();
 }
 /// <summary>
 /// Department insert
 /// </summary>
 /// <param name="department">Department to insert</param>
 public void Add(Department department)
 {
     _unitOfWork.Repository <Department>().Add(department);
     _unitOfWork.SaveChanges();
 }