Esempio n. 1
0
        public bool AddNewFeedbackMail(Notification notification, User addedFor, int feedbackId)
        {
            User         addedByUser  = UserDataAccesor.GetUserById(notification.AddedBy);
            EmailContent emailContent = GetEmailContent(notification
                                                        , addedByUser
                                                        , notification.Title);

            emailContent.EmailRecipients.Add(new EmailRecipient
            {
                EmailAddress       = addedFor.Email,
                EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
            });


            foreach (var user in UnitOfWork.EmailAlertSubscriptionRepository.GetAllSubscribedMentors(addedFor.UserId)
                     .Where(user => user.SubscribedByUserId != addedByUser.UserId))
            {
                emailContent.EmailRecipients.Add(new EmailRecipient
                {
                    EmailAddress       = user.User.Email,
                    EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.CarbonCopy
                });
            }

            UnitOfWork.EmailRepository.Add(emailContent); //TODO:EmailRepository needs to be EmailContentRepository.
            return(UnitOfWork.Commit() > 0);
        }
Esempio n. 2
0
        public bool AddSessionMail(Notification notification, Common.Entity.Session session)
        {
            User         addedByUser  = UserDataAccesor.GetUserById(notification.AddedBy);
            EmailContent emailContent = GetEmailContent(notification
                                                        , addedByUser
                                                        , notification.Title);

            foreach (var user in UnitOfWork.SessionRepository.GetSessionWithAttendees(session.Id).UserSessionMappings)
            {
                emailContent.EmailRecipients.Add(new EmailRecipient
                {
                    EmailAddress       = user.User1.Email,
                    EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
                });
            }

            emailContent.EmailRecipients.Add(new EmailRecipient
            {
                EmailAddress       = addedByUser.Email,
                EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.CarbonCopy
            });

            UnitOfWork.EmailRepository.Add(emailContent); //TODO:EmailRepository needs to be EmailContentRepository.
            return(UnitOfWork.Commit() > 0);
        }
Esempio n. 3
0
        public async Task <List <User> > SyncGPSUsers(User currentUser)
        {
            List <User> gpsMembersUnderLead = await GetMembersUnderLead(currentUser.EmployeeId);

            List <User> ttMembersUnderLead = GetManageProfileVm(currentUser).AllUser;
            List <User> unsyncedMembers    = new List <User>();

            foreach (var gpsMember in gpsMembersUnderLead)
            {
                foreach (var ttMember in ttMembersUnderLead)
                {
                    if (ttMember.UserName == gpsMember.UserName)
                    {
                        ttMember.EmployeeId = gpsMember.EmployeeId;
                        if (!UserDataAccesor.UpdateUser(ttMember))
                        {
                            unsyncedMembers.Add(ttMember);
                        }
                    }
                    else
                    {
                        unsyncedMembers.Add(ttMember);
                    }
                }
            }
            return(unsyncedMembers);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        public bool AddNewDiscussionMail(Notification notification)
        {
            User addedByUser = UserDataAccesor.GetUserById(notification.AddedBy);
            List <EmailAlertSubscription> subscriptionList = UnitOfWork.EmailAlertSubscriptionRepository
                                                             .GetAllSubscribedMentors(addedByUser.UserId)
                                                             .Where(x => x.SubscribedByUserId != addedByUser.UserId)
                                                             .Distinct()
                                                             .ToList();

            if (!subscriptionList.Any())
            {
                return(true);                         // escape the routine if no one is subscribed to this trainee.
            }
            EmailContent emailContent = GetEmailContent(notification, addedByUser, notification.Title);

            foreach (var user in subscriptionList)
            {
                emailContent.EmailRecipients.Add(new EmailRecipient
                {
                    EmailAddress       = user.User.Email,
                    EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
                });
            }

            UnitOfWork.EmailRepository.Add(emailContent);
            return(UnitOfWork.Commit() > 0);
        }
Esempio n. 6
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        /// <returns>User data with validation information.</returns>
        public async Task <User> GPSAuthentication(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName))
            {
                return(null);
            }

            var responseBody = await GPSService.GPSService.AuthenticateUser(Constants.GpsWebApiUrl, Constants.GpsWebApiUrl, Constants.ApiKey, Constants.AppId, userName, password);

            var userData = new User
            {
                UserName = userName,
                Password = password,
                IsValid  = JsonConvert.DeserializeObject <bool>(responseBody)
            };

            if (!userData.IsValid)
            {
                return(userData);
            }

            var userExists = UserDataAccesor.GetUserByUserName(userName);

            if (userExists == null || userExists.UserId == 0)
            {
                return(null);
            }

            userExists.IsValid = userData.IsValid;
            return(userExists);
        }
Esempio n. 7
0
        public SessionVm GetSessionOnFilter(int pageSize, int sessionType, string searchKeyword)
        {
            SessionVm objSessionVm = new SessionVm
            {
                SessionList  = SessionDataAccesor.GetSessionOnFilter(pageSize, sessionType, searchKeyword),
                AllAttendees = UserDataAccesor.GetAllUsers()
            };

            return(objSessionVm);
        }
Esempio n. 8
0
        public Course GetCourseWithSubtopics(int courseId)
        {
            var courseDetails = LearningPathDataAccessor.GetCourseWithSubtopics(courseId);

            if (courseDetails != null)
            {
                courseDetails.AuthorName = UserDataAccesor.GetUserById(courseDetails.AddedBy).FirstName;
            }
            return(courseDetails);
        }
Esempio n. 9
0
        /// <summary>
        /// Authenticates the user.
        /// </summary>
        /// <returns>User data with validation information.</returns>
        public User AuthenticateUser(string userName, string password)
        {
            var userData = new User
            {
                UserName = userName,
                Password = password
            };

            userData.IsValid = UserDataAccesor.ValidateUser(userData);
            return(userData);
        }
Esempio n. 10
0
        /// <summary>
        /// Function for getting list of active user.
        /// </summary>
        /// <returns>Returns list of active user.</returns>
        public List <User> GetActiveUsers(User currentUser)
        {
            if (currentUser.IsAdministrator && !currentUser.TeamId.HasValue)
            {
                return(UserDataAccesor.GetActiveUsers());
            }

            return(currentUser.TeamId.HasValue
                              ? UserDataAccesor.GetActiveUsersByTeam(currentUser.TeamId.Value).Where(x => !currentUser.IsTrainee || !x.IsTrainee || x.UserId == currentUser.UserId).ToList()
                              : new List <User>());
        }
Esempio n. 11
0
        /// <summary>
        /// GEt all user
        /// </summary>
        /// <returns>List of User</returns>
        public List <User> GetAllUsersByTeam(User currentUser)
        {
            if (currentUser.IsAdministrator && !currentUser.TeamId.HasValue)
            {
                return(UserDataAccesor.GetAllUsers());
            }

            return(currentUser.TeamId.HasValue
                              ? UserDataAccesor.GetAllUsersForTeam(currentUser.TeamId.Value)
                              : new List <User>());
        }
Esempio n. 12
0
        public bool AddNewDiscussionThreadMail(Notification notification, int discussionPostId)
        {
            User addedByUser = UserDataAccesor.GetUserById(notification.AddedBy);
            ForumDiscussionPost           forumDiscussionPost = UnitOfWork.ForumDiscussionPostRepository.GetPostWithThreads(discussionPostId);
            List <EmailAlertSubscription> subscriptionList    = UnitOfWork.EmailAlertSubscriptionRepository
                                                                .GetAllSubscribedMentors(forumDiscussionPost.AddedBy)
                                                                .Where(x => x.SubscribedByUserId != addedByUser.UserId)
                                                                .ToList();

            EmailContent emailContent = GetEmailContent(notification, addedByUser, notification.Title);

            List <DAL.EntityFramework.User> allUsers = forumDiscussionPost.ForumDiscussionThreads.Where(x => x.AddedBy != addedByUser.UserId)
                                                       .Select(x => x.User)
                                                       .Union(subscriptionList.Select(x => x.User))
                                                       .ToList();

            if (addedByUser.UserId != forumDiscussionPost.AddedBy)
            {
                emailContent.EmailRecipients.Add(new EmailRecipient
                {
                    EmailAddress       = forumDiscussionPost.User.Email,
                    EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
                });

                foreach (DAL.EntityFramework.User user in allUsers)
                {
                    emailContent.EmailRecipients.Add(new EmailRecipient
                    {
                        EmailAddress       = user.Email,
                        EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.CarbonCopy
                    });
                }
            }
            else
            {
                if (!allUsers.Any())
                {
                    return(true);                 // / escape the routine if no one is subscribed to this trainee.
                }
                foreach (DAL.EntityFramework.User user in allUsers)
                {
                    emailContent.EmailRecipients.Add(new EmailRecipient
                    {
                        EmailAddress       = user.Email,
                        EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
                    });
                }
            }
            UnitOfWork.EmailRepository.Add(emailContent);
            return(UnitOfWork.Commit() > 0);
        }
Esempio n. 13
0
        public bool AddNewDiscussionPostNotification(ForumPost post)
        {
            var notification = new Notification
            {
                Description        = post.AddedByUser.FirstName + " " + post.AddedByUser.LastName,
                Link               = string.Format(DiscussionPostLink, post.AddedBy, post.PostId),
                TypeOfNotification = NotificationType.NewDiscussionPostNotification,
                AddedBy            = post.AddedBy,
                Title              = "New Post in Discussion Forum",
                AddedOn            = DateTime.Now,
            };

            new MailerBl().AddNewDiscussionMail(notification);
            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, post.AddedBy)));
        }
Esempio n. 14
0
        public bool AddNewDiscussionThreadNotification(ForumThread thread)
        {
            var notification = new Notification
            {
                Description        = thread.AddedByUser.FirstName + " " + thread.AddedByUser.LastName,
                Link               = string.Format(DiscussionPostLink, thread.AddedFor, thread.PostId),
                TypeOfNotification = NotificationType.NewDiscussionThreadNotification,
                AddedBy            = thread.AddedBy,
                Title              = "New Comment on Discussion Post",
                AddedOn            = DateTime.Now,
            };

            new MailerBl().AddNewDiscussionThreadMail(notification, thread.PostId);
            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, thread.AddedFor)));
        }
Esempio n. 15
0
        /// <summary>
        /// Calls stored procedure which updates user.
        /// </summary>
        /// <param name="userData">User data object.</param>
        /// <param name="addedById">manager id</param>
        /// <returns>True if updated.</returns>
        public bool UpdateUser(User userData, int addedById)
        {
            userData.Password = Cryptography.Encrypt(userData.Password);
            var isUserUpdated = UserDataAccesor.UpdateUser(userData);
            var dbUser        = GetUserByUserId(userData.UserId);
            var teamManagers  = UnitOfWork.UserRepository
                                .Find(u => u.TeamId == dbUser.TeamId && u.IsManager == true)
                                .Select(lead => lead.UserId)
                                .ToList();

            try
            {
                if (isUserUpdated && dbUser.IsTrainee)
                {
                    UnitOfWork.EmailAlertSubscriptionRepository
                    .GetAllSubscribedMentors(userData.UserId, includeDeleted: true)
                    .ForEach(s =>
                    {
                        s.IsDeleted = !(userData.IsActive && teamManagers.Contains(s.SubscribedByUserId));
                        teamManagers.Remove(s.SubscribedByUserId);                   //Remove from managers if record exists. Also avoids duplicate notifications.
                        UnitOfWork.EmailAlertSubscriptionRepository.AddOrUpdate(s);
                    });

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

                    UnitOfWork.Commit();

                    if (dbUser.IsActive)
                    {
                        new NotificationBl().UserNotification(dbUser, addedById, isNewUser: false);
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtility.ErrorRoutine(ex);
                isUserUpdated = false;
            }

            return(isUserUpdated);
        }
Esempio n. 16
0
        /// <summary>
        /// Get view model for user profile page
        /// </summary>
        /// <param name="userId">user id</param>
        /// <param name="loggedInUser"></param>
        /// <returns>instance of User vm</returns>
        public UserProfileVm GetUserProfileVm(int userId, User loggedInUser)
        {
            User requestedUser = userId == loggedInUser.UserId ? loggedInUser : UserDataAccesor.GetUserById(userId);

            CodeReview codeReview = loggedInUser.IsTrainer || loggedInUser.IsManager
                                        ? CodeReviewConverter.ConvertFromCore(UnitOfWork.CodeReviewRepository.GetSavedCodeReviewForTrainee(userId, loggedInUser.UserId))
                                        : null;
            var commonTags = UnitOfWork.CodeReviewRepository
                             .GetCommonlyUsedTags(userId, 5)
                             .Select(skill => new CodeReviewTag
            {
                CodeReviewTagId = 0,
                Skill           = new Skill
                {
                    Name    = skill.Name,
                    SkillId = skill.SkillId
                }
            }).ToList();

            if (codeReview != null)
            {
                codeReview.CodeReviewPreviewHtml = UtilityFunctions.GenerateCodeReviewPreview(codeReview, true);
                codeReview.SystemRating          = new FeedbackBl().CalculateCodeReviewRating(codeReview);
            }

            return(new UserProfileVm
            {
                User = userId == loggedInUser.UserId ? null : requestedUser,
                Skills = requestedUser.IsTrainee ? SkillDataAccesor.GetSkillsByUserId(userId) : null,
                TraineeSynopsis = requestedUser.IsTrainee ? FeedbackDataAccesor.GetTraineeFeedbackSynopsis(requestedUser.UserId) : null,
                Sessions = requestedUser.IsTrainee ? SessionConverter.ConvertListFromCore(UnitOfWork.SessionRepository.GetAllSessionForAttendee(userId)) : null,
                Projects = null,
                Feedbacks = requestedUser.IsTrainee ? FeedbackDataAccesor.GetUserFeedback(userId, 5) : FeedbackDataAccesor.GetFeedbackAddedByUser(userId),
                TrainorSynopsis = requestedUser.IsTrainer || requestedUser.IsManager ? FeedbackDataAccesor.GetTrainorFeedbackSynopsis(requestedUser.UserId) : null,
                AllAssignedCourses = requestedUser.IsTrainee ? LearningPathDataAccessor.GetAllCoursesForTrainee(requestedUser.UserId).OrderByDescending(x => x.PercentageCompleted).ToList() : new List <CourseTrackerDetails>(),
                SavedCodeReview = codeReview,
                CommonTags = commonTags
                             //  SavedCodeReviewData = logedInUser.IsTrainer && (codeReview != null && codeReview.Id > 0) ? UtilityFunctions.GenerateCodeReviewPreview(codeReview, true) : string.Empty
            });
        }
Esempio n. 17
0
        public Course GetCourseWithAllData(int courseId, User currentUser, int userId = 0)
        {
            Course courseDetails;

            if (!currentUser.IsTrainee)
            {
                if (userId > 0)
                {
                    courseDetails = LearningPathDataAccessor.GetCourseWithAllData(courseId, userId);
                    courseDetails.TrackerDetails = LearningPathDataAccessor.GetAllCoursesForTrainee(userId).FirstOrDefault(x => x.Id == courseId);
                }
                else
                {
                    courseDetails = LearningPathDataAccessor.GetCourseWithAllData(courseId);
                }
            }
            else
            {
                courseDetails = LearningPathDataAccessor.GetCourseWithAllData(courseId, userId);
            }

            if (courseDetails != null)
            {
                User userData = UserDataAccesor.GetUserById(courseDetails.AddedBy);
                courseDetails.AuthorName   = userData.FirstName;
                courseDetails.AuthorMailId = userData.Email;

                if (currentUser.IsTrainee && !courseDetails.IsStarted)
                {
                    courseDetails.LoadAlert = true;
                    foreach (CourseSubtopic subtopic in courseDetails.CourseSubtopics)
                    {
                        subtopic.Assignments      = new Collection <Assignment>();
                        subtopic.SubtopicContents = new Collection <SubtopicContent>();
                    }
                }
            }
            return(courseDetails);
        }
Esempio n. 18
0
        /// <summary>
        /// Function which add user notification
        /// Calls AddNotification() to save in the database.
        /// </summary>
        /// <param name="user">Release object</param>
        /// <param name="managerId">manager Id</param>
        /// <param name="isNewUser">true if user is new</param>
        /// <returns>Returns true if Notification is added successfully else false.</returns>
        internal bool UserNotification(User user, int managerId, bool isNewUser = true)
        {
            var notificationManagementLink = "/Setting/UserSetting?settingName=Notification&user="******"New user ""{0}"" added!", user.FullName)
                                   : string.Format(@"User ""{0}"" has been activated.", user.FullName));

            var notification = new Notification
            {
                Description        = description,
                Link               = notificationManagementLink,
                TypeOfNotification = isNewUser ? NotificationType.NewUserNotification
                                                            : NotificationType.UserActivatedNotification,
                AddedBy = managerId,
                Title   = description,
                AddedOn = DateTime.Now,
            };

            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, managerId)));
        }
Esempio n. 19
0
        /// <summary>
        /// Function which add help notification
        /// Calls AddNotification() to save in the database.
        /// </summary>
        /// <param name="forumPost">Release object</param>
        /// <param name="userId">UseId</param>
        /// <returns>Returns true if Notification is added successfully else false.</returns>
        internal bool AddHelpNotification(ForumPost forumPost, int userId)
        {
            string featureText, helpLink;

            switch (forumPost.CategoryId)
            {
            case (int)ForumUserHelpCategories.Bug:
                featureText = "New Bug Raised";
                helpLink    = string.Format(HelpLink, "Bugs");
                break;

            case (int)ForumUserHelpCategories.Help:
                featureText = "Need a Help ";
                helpLink    = string.Format(HelpLink, "Help");
                break;

            case (int)ForumUserHelpCategories.Idea:
                featureText = "New Idea for TT";
                helpLink    = string.Format(HelpLink, "Idea");
                break;

            default:
                featureText = "New Activity";
                helpLink    = string.Format(HelpLink, "");
                break;
            }

            var notification = new Notification
            {
                Description        = "",
                Link               = helpLink,
                TypeOfNotification = NotificationType.NewFeatureRequestNotification,
                AddedBy            = userId,
                Title              = featureText,
                AddedOn            = DateTime.Now,
            };

            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, userId)));
        }
Esempio n. 20
0
        /// <summary>
        /// Add Notification for Thread
        /// </summary>
        /// <param name="thread"></param>
        internal bool AddNewThreadNotification(Threads thread)
        {
            int userId = FeedbackDataAccesor.GetTraineebyFeedbackId(thread.FeedbackId);

            if (userId == 0)
            {
                return(false);
            }

            var notification = new Notification
            {
                Description        = "New Note Added To Feedback",
                Link               = string.Format(FeedbackLink, userId, thread.FeedbackId),
                TypeOfNotification = NotificationType.NewNoteToFeedback,
                AddedBy            = thread.AddedBy.UserId,
                Title              = "New Note Added to Feedback",
                AddedOn            = DateTime.Now,
            };

            new MailerBl().AddNewFeedbackThreadMail(notification, thread.FeedbackId);
            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, userId)));
        }
Esempio n. 21
0
        /// <summary>
        /// Function which takes version generates notification message, list of userId, link
        /// Calls AddNotification() to save in the database.
        /// </summary>
        /// <param name="release">Release object</param>
        /// <param name="userId">UseId</param>
        /// <returns>Returns true if Notification is added successfully else false.</returns>
        internal bool AddReleaseNotification(Release release, int userId)
        {
            NotificationType notificationType;
            string           featureText;

            if (!release.IsPublished)
            {
                // This feature has gone obsolete.

                if (release.IsNew)
                {
                    notificationType = NotificationType.NewFeatureRequestNotification;
                    featureText      = "New Feature/Bug Request";
                }
                else
                {
                    notificationType = NotificationType.FeatureModifiedNotification;
                    featureText      = "Feature Details Updated";
                }
            }
            else
            {
                notificationType = NotificationType.NewReleaseNotification;
                featureText      = "New Release";
            }

            var notification = new Notification
            {
                Description        = ReleaseDescription + release.Major + "." + release.Minor + "." + release.Patch,
                Link               = string.Format(ReleaseLink, release.ReleaseId),
                TypeOfNotification = notificationType,
                AddedBy            = userId,
                Title              = featureText,
                AddedOn            = release.ReleaseDate ?? DateTime.Now,
            };

            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, userId)));
        }
Esempio n. 22
0
        public DashboardVm GetDashboardData()
        {
            var dashboardVm = new DashboardVm
            {
                Trainees         = UserDataAccesor.GetDashboardData(),
                UpcomingSessions = SessionDataAccesor.GetSessionOnFilter(100, 1, "")
            };

            var lastFriday = DateTime.Now;

            while (lastFriday.DayOfWeek != DayOfWeek.Friday)
            {
                lastFriday = lastFriday.AddDays(-1);
            }

            foreach (var trainee in dashboardVm.Trainees)
            {
                bool feedbackAdded = false;
                foreach (var feedback in trainee.WeeklyFeedback)
                {
                    feedback.WeekForFeedbackPresent = string.Empty;

                    if (feedback.StartDate >= lastFriday.AddDays(-5))
                    {
                        feedbackAdded = true;
                    }

                    feedback.WeekForFeedbackPresent = feedback.StartDate.ToString("dd/MM/yyyy") + "-" + feedback.EndDate.ToString("dd/MM/yyyy");
                }
                trainee.LastWeekFeedbackAdded = feedbackAdded;

                // trainee.IsFeedbackPending = !(trainee.LastWeeklyFeedback > checkLowerDate && trainee.LastWeeklyFeedback <= lastFriday);
            }

            return(dashboardVm);
        }
Esempio n. 23
0
 public UserProfileVm GetUserProfileVm(int userId)
 {
     return(new UserProfileVm
     {
         User = UserDataAccesor.GetUserById(userId),
         Skills = SkillDataAccesor.GetSkillsByUserId(userId),
         AllSkills = SkillDataAccesor.GetAllSkillsForApp(),
         Sessions = SessionDataAccesor.GetSessionsByUserId(userId),
         Projects = ProjectDataAccesor.GetProjectsByUserId(userId),
         Feedbacks = FeedbackDataAccesor.GetUserFeedback(userId, 5),
         RecentCrFeedback = FeedbackDataAccesor.GetUserFeedback(userId, 100, 4),
         FeedbackTypes = new List <FeedbackType>
         {
             new FeedbackType
             {
                 FeedbackTypeId = 1, Description = "Comment"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 2, Description = "Skill"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 3, Description = "Assignment"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 4, Description = "Code Review"
             },
             new FeedbackType
             {
                 FeedbackTypeId = 5, Description = "Weekly Feedback"
             }
         }
     });
 }
Esempio n. 24
0
 /// <summary>
 ///  Get List of all trainees which belongs to given teamId
 /// </summary>
 /// <param name="teamId">teamId </param>
 /// <returns>List of trainees if exists otherwise null</returns>
 public List <User> GetAllTrainees(int teamId)
 {
     return(UserDataAccesor.GetAllTrainees(teamId));
 }
Esempio n. 25
0
 /// <summary>
 /// Get all designation
 /// </summary>
 /// <returns>List of Designation</returns>
 public List <Designation> GetAllDesignation()
 {
     return(UserDataAccesor.GetAllDesignation());
 }
Esempio n. 26
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));
 }
Esempio n. 27
0
        /// <summary>
        /// Function which takes feedback data and user list to whom notification is to be added,
        /// Calls AddNotification() to save in the database.
        /// </summary>
        /// <param name="feedback">Contain Feedback object as parameter.</param>
        /// <returns>Returns a boolean value as feedback notification is added successfully or not.</returns>
        internal bool AddFeedbackNotification(Feedback feedback)
        {
            NotificationType notificationType;
            string           notificationText = string.Empty;

            switch ((FeedbackType)feedback.FeedbackType.FeedbackTypeId)
            {
            case FeedbackType.Weekly:
            {
                notificationType = NotificationType.WeeklyFeedbackNotification;
                notificationText = "New Weekly Feedback";
                break;
            }

            case FeedbackType.Comment:
            {
                notificationType = NotificationType.CommentFeedbackNotification;
                notificationText = "New Comment";
                break;
            }

            case FeedbackType.Skill:
            {
                notificationType = NotificationType.SkillFeedbackNotification;
                notificationText = "New Skill";
                break;
            }

            case FeedbackType.Assignment:
            {
                notificationType = NotificationType.AssignmentFeedbackNotification;
                notificationText = "New Assignment Feedback";
                break;
            }

            case FeedbackType.CodeReview:
            {
                notificationType = NotificationType.CodeReviewFeedbackNotification;
                notificationText = "New CR Feedback";
                break;
            }

            case FeedbackType.Course:
            {
                notificationType = NotificationType.CourseFeedbackNotification;
                notificationText = "New Course Feedback";
                break;
            }

            case FeedbackType.RandomReview:
            {
                notificationType = NotificationType.RandomReviewFeedbackNotification;
                notificationText = "New Random Review";
                break;
            }

            default:
            {
                return(false);
            }
            }

            var user = UserDataAccesor.GetUserById(feedback.AddedFor.UserId);

            var notification = new Notification
            {
                Description        = user.FirstName + " " + user.LastName,
                Link               = string.Format(FeedbackLink, feedback.AddedFor.UserId, feedback.FeedbackId),
                TypeOfNotification = notificationType,
                AddedBy            = feedback.AddedBy.UserId,
                Title              = notificationText,
                AddedOn            = DateTime.Now,
            };

            new MailerBl().AddNewFeedbackMail(notification, user, feedback.FeedbackId);
            return(AddNotification(notification, UserDataAccesor.GetUserId(notification, feedback.AddedFor.UserId)));
        }
Esempio n. 28
0
        public bool AddNewFeedbackThreadMail(Notification notification, int feedbackId)
        {
            // This need to be changed... but How!!
            var addedByUser = UserDataAccesor.GetUserById(notification.AddedBy);

            Feedback feedback = UnitOfWork.FeedbackRepository.Get(feedbackId);

            EmailContent emailContent = GetEmailContent(notification
                                                        , addedByUser
                                                        , notification.Title);


            if (notification.AddedBy == feedback.User1.UserId)
            {
                emailContent.EmailRecipients.Add(new EmailRecipient
                {
                    EmailAddress       = feedback.User.Email,
                    EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
                });
            }
            else
            {
                emailContent.EmailRecipients.Add(new EmailRecipient
                {
                    EmailAddress       = feedback.User1.Email,
                    EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.To
                });

                if (notification.AddedBy != feedback.User.UserId)
                {
                    emailContent.EmailRecipients.Add(new EmailRecipient
                    {
                        EmailAddress       = feedback.User.Email,
                        EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.CarbonCopy
                    });
                }
            }

            foreach (var user in UnitOfWork.EmailAlertSubscriptionRepository.GetAllSubscribedMentors(feedback.User1.UserId)
                     .Where(user => user.SubscribedByUserId != addedByUser.UserId))
            {
                if (emailContent.EmailRecipients.All(x => x.EmailAddress != user.User.Email))
                {
                    emailContent.EmailRecipients.Add(new EmailRecipient
                    {
                        EmailAddress       = user.User.Email,
                        EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.CarbonCopy
                    });
                }
            }


            foreach (var thread in feedback.FeedbackThreads.Where(user => user.AddedBy != addedByUser.UserId))
            {
                if (emailContent.EmailRecipients.All(x => x.EmailAddress != thread.User.Email))
                {
                    emailContent.EmailRecipients.Add(new EmailRecipient
                    {
                        EmailAddress       = thread.User.Email,
                        EmailRecipientType = (int)Common.Enumeration.EmailRecipientType.CarbonCopy
                    });
                }
            }

            UnitOfWork.EmailRepository.Add(emailContent);
            return(UnitOfWork.Commit() > 0);
        }
Esempio n. 29
0
 public List <User> GetAllUsers()
 {
     return(UserDataAccesor.GetAllUsers());
 }
Esempio n. 30
0
 public User GetUserByUserName(string userName)
 {
     return((string.IsNullOrEmpty(userName)) ? new User() : UserDataAccesor.GetUserByUserName(userName));
 }