Пример #1
0
        /// <summary>
        /// Calls stored procedure which adds user.
        /// </summary>
        /// <param name="userData">User data object.</param>
        /// <param name="managerId">Id of manager adding.</param>
        /// <param name="userId">Out parameter created UserId.</param>
        /// <returns>True if added.</returns>
        public bool AddUser(User userData, int managerId, out int userId)
        {
            userData.Password = Cryptography.Encrypt(userData.Password);
            var isUserAdded = UserDataAccesor.AddUser(userData, out userId);

            var dbUser = GetUserByUserId(userId);

            var teamManagers = UnitOfWork.UserRepository
                               .Find(u => u.TeamId == dbUser.TeamId && u.IsManager == true)
                               .Select(lead => lead.UserId)
                               .ToList();

            if (isUserAdded)
            {
                teamManagers.ForEach(manager => UnitOfWork.EmailAlertSubscriptionRepository
                                     .AddOrUpdate(new EmailAlertSubscription
                {
                    SubscribedByUserId  = manager,
                    SubscribedForUserId = dbUser.UserId
                }));
                UnitOfWork.Commit();
            }

            if (isUserAdded && dbUser.IsTrainee)
            {
                new NotificationBl().UserNotification(dbUser, managerId);
            }

            return(isUserAdded);
        }
Пример #2
0
 /// <summary>
 /// Calls stored procedure which adds user.
 /// </summary>
 /// <param name="userData">User data object.</param>
 /// <returns>True if added.</returns>
 public bool AddUser(User userData)
 {
     return(UserDataAccesor.AddUser(userData));
 }