예제 #1
0
        private static void AddExtraitCodeApprouver(int idEc)
        {
            ExtraitCodeApprouved eca = new ExtraitCodeApprouved(listExtraitsCodeApprouved[listExtraitsCodeApprouved.Count - 1].Id + 1, idEc, new List <int> {
                UserConnected.GetUserConnected().Id
            });

            listExtraitsCodeApprouved.Add(eca);
        }
예제 #2
0
        private static void AddApprouverToExtraitCode(int idEc)
        {
            ExtraitCodeApprouved eca = GetListExtraitsCodeApprouved().Find(x => x.IdExtraitCode == idEc);

            eca.ListApprouver.Add(UserConnected.GetUserConnected().Id);
        }
예제 #3
0
        public ExtraitCodeItem(ExtraitCode extraitCode)
        {
            InitializeComponent();
            if (!UserConnected.VerifyHabilitation("100_4xCD0"))
            {
                DeleteExtraitCodeIcon.Cursor = Cursors.No;
            }
            if (!UserConnected.VerifyHabilitation("100_1xCMT"))
            {
                AddComment.Cursor     = Cursors.No;
                AddComment.Text       = "";
                AddComment.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#EB4034"));
            }
            if (!UserConnected.VerifyHabilitation("100_5xCD0"))
            {
                StarNote1.Cursor = Cursors.No;
                StarNote2.Cursor = Cursors.No;
                StarNote3.Cursor = Cursors.No;
                StarNote4.Cursor = Cursors.No;
                StarNote5.Cursor = Cursors.No;
            }
            ec = extraitCode;
            _listApprouvedUser = new List <User>();
            OrganizeListComment();
            if (_listComments.Count == 0 || _listComments == null)
            {
                this.CommentBlock.Children.Remove(ListComments);
                TextBlock NoComments = new TextBlock
                {
                    Text                = "Pas de commentaire...",
                    Foreground          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF")),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center
                };
                this.CommentBlock.Children.Add(NoComments);
            }
            ExtraitCodeApprouved extraitCodeApprouved = dataUtils.GetListExtraitsCodeApprouved().Find(x => x.IdExtraitCode == extraitCode.Id);

            if (extraitCodeApprouved == null)
            {
                this.ApprouvedBlock.Visibility = Visibility.Hidden;
            }
            else
            {
                foreach (int i in extraitCodeApprouved.ListApprouver)
                {
                    _listApprouvedUser.Add(dataUtils.GetListUsers().Find(x => x.Id == i));
                }
                if (!UserConnected.GetUserConnected().GetIdRoles().Contains(1) || !UserConnected.GetUserConnected().GetIdRoles().Contains(2) || !UserConnected.GetUserConnected().GetIdRoles().Contains(5))
                {
                    this.ApprouveExtraitCodeIcon.Visibility = Visibility.Hidden;
                }
                else
                {
                    if (_listApprouvedUser.Contains(UserConnected.GetUserConnected()))
                    {
                        this.ApprouveExtraitCodeIcon.Icon       = FontAwesome.WPF.FontAwesomeIcon.CheckCircle;
                        this.ApprouveExtraitCodeIcon.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2F528F"));
                    }
                    else
                    {
                        this.ApprouveExtraitCodeIcon.Icon       = FontAwesome.WPF.FontAwesomeIcon.CheckCircleOutline;
                        this.ApprouveExtraitCodeIcon.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#BFBFBF"));
                    }
                }
            }
            Binding binding = new Binding
            {
                Mode = BindingMode.OneWay
            };

            this.ExtraitCode_Creator.Text = dataUtils.GetListUsers().Find(x => x.Id == extraitCode.IdCreator).Nom + " " +
                                            dataUtils.GetListUsers().Find(x => x.Id == extraitCode.IdCreator).Prenom;
            this.ListComments.ItemsSource     = _listItemComment;
            this.ExtraitCode_Title.Text       = extraitCode.Title;
            this.ExtraitCode_Description.Text = extraitCode.Description;
            List <int> idRoles = UserConnected.GetUserConnected().GetIdRoles();

            if (UserConnected.GetUserConnected().Id == ec.IdCreator || idRoles.Contains(1) || idRoles.Contains(2) || idRoles.Contains(3) || idRoles.Contains(4) || idRoles.Contains(5))
            {
                this.DeleteExtraitCodeIcon.Visibility = Visibility.Visible;
            }
            else
            {
                this.DeleteExtraitCodeIcon.Visibility = Visibility.Collapsed;
            }
            Favoris isFavoris = dataUtils.GetListFavoris().Find(x =>
                                                                (x.IdTarget == ec.Id) &&
                                                                (x.IdUser == UserConnected.GetUserConnected().Id) &&
                                                                (x.TypeTarget.Equals("ExtraitCode"))
                                                                );

            if (isFavoris != null)
            {
                this.FavorisExtraitCodeIcon.Icon = FontAwesome.WPF.FontAwesomeIcon.Heart;
            }
            else
            {
                this.FavorisExtraitCodeIcon.Icon = FontAwesome.WPF.FontAwesomeIcon.HeartOutline;
            }
            this.ExtraitCode_Code.Text = TextEncoder.DecodeText(extraitCode.Code);
            this.ExtraitCode_Note.Text = extraitCode.Note.ToString();
            DisplayTotalVote(dataUtils.GetListVote().Where(x => (x.IdTarget == extraitCode.Id) && (x.TypeTarget.Equals("ExtraitCode"))).ToList().Count);
            ChangePersonalVote(extraitCode);
            ChangeApprouverList(_listApprouvedUser);
            this.Picture_Creator.ImageSource = new BitmapImage
                                               (
                new Uri(String.Format("pack://application:,,,/Resources/" + dataUtils.GetListUsers().Find(x => x.Id == extraitCode.IdCreator).Picture))
                                               );
            this.ExtraitCode_DateCreation.Text = RebuildDateCreation(extraitCode.Date_Creation);
        }