public bool AddDepUnQuizzmateNotification(int toUnQuizzmateId, bool callSaveChanges = true)
        {
            try
            {
                var  quizzlingId = _currentUser.Id;
                User dependent   = _uow.Users.GetAll()
                                   .Where(u => u.Id == quizzlingId)
                                   .Include(u => u.DependentPermission)
                                   .Include(u => u.AsChildDependsOn.Select(d => d.User))
                                   .FirstOrDefault();

                if (dependent.UserType == UserTypeEnum.Standard)
                {
                    return(true);
                }

                foreach (var depEntity in dependent.AsChildDependsOn)
                {
                    if (NotificationTypeUtil.WillNotify(depEntity, NotificationTypeEnum.DepUnQuizzmate) == false)
                    {
                        continue;
                    }

                    var editor = new NewNotificationEditor(NotificationTypeEnum.DepUnQuizzmate, quizzlingId, depEntity.UserId);
                    editor.AddToUnQuizzmateUser(toUnQuizzmateId);
                    var entity = editor.GetEntity();
                    _uow.NewNotifications.Add(entity);
                }

                if (callSaveChanges)
                {
                    _uow.SaveChanges();
                }

                return(true);
            }
            catch (Exception ex)
            {
                _svcContainer.LoggingSvc.Log(ex);
                return(false);
            }
        }
        private bool AddDepQuizzmateNotification(NotificationTypeEnum type, User dependent, FriendRequest friendRequest)
        {
            if (dependent.UserType == UserTypeEnum.Standard)
            {
                return(true);
            }

            foreach (var depEntity in dependent.AsChildDependsOn)
            {
                if (depEntity.UserId == friendRequest.RequestFromId)
                {
                    continue;
                }
                if (NotificationTypeUtil.WillNotify(depEntity, type) == false)
                {
                    continue;
                }

                CreateNewQuizzmateNotification(type, friendRequest.Id, dependent.Id, depEntity.UserId);
            }

            return(true);
        }
        private bool AddQuizzNotification(NotificationTypeEnum type, int quizzId, bool callSaveChanges = true)
        {
            try
            {
                var dependent = _uow.Quizzes.GetAll()
                                .Where(q => q.Id == quizzId)
                                .Select(q => q.Owner)
                                .Include(u => u.DependentPermission)
                                .Include(u => u.AsChildDependsOn.Select(d => d.User))
                                .FirstOrDefault();

                if (dependent.UserType == UserTypeEnum.Standard)
                {
                    return(true);
                }

                var quizz = _uow.Quizzes.GetById(quizzId);

                if (quizz == null)
                {
                    return(false);
                }

                foreach (var depEntity in dependent.AsChildDependsOn)
                {
                    if (isParentCurrentUser(depEntity))
                    {
                        continue;
                    }

                    if (type == NotificationTypeEnum.DepQuizzReceiveComment && isCurrentUserQuizzOwner(quizz))
                    {
                        continue;
                    }

                    if (NotificationTypeUtil.WillNotify(depEntity, type) == false)
                    {
                        continue;
                    }

                    var entity = _uow.NewNotifications.GetAll()
                                 .Where(n => n.NotificationType == type &&
                                        n.QuizzId == quizzId &&
                                        n.ToUserId == depEntity.User.Id)
                                 .FirstOrDefault();

                    if (entity == null)
                    {
                        CreateNewQuizzNotification(type, quizzId, depEntity.UserId);
                    }
                    else
                    {
                        UpdateQuizzNotification(entity);
                    }
                }

                if (callSaveChanges)
                {
                    _uow.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                _svcContainer.LoggingSvc.Log(ex);
                return(false);
            }
        }