Пример #1
0
        /// <summary>
        /// This method downloads the file of the FTP server
        /// </summary>
        /// <param name="post"></param>
        private void DownloadMedia(Post post)
        {
            if (post.MediaID == 0) return;

            _media = LogicCollection.MediaLogic.GetById(post.MediaID);

            var saveMedia = new FolderBrowserDialog();

            if (saveMedia.ShowDialog() != DialogResult.OK) return;

            var pathSelected = saveMedia.SelectedPath;

            var succeeded = false;
            if (_media.Type == MediaType.Image)
            {
                try
                {
                    pbMediaMessage.Image.Save($"{pathSelected}/{_media.Path}");
                    succeeded = true;
                }
                catch (IOException e)
                {
                    Logger.Write(e.Message);
                    succeeded = false;
                }
            }
            else
            {
                succeeded = FtpHelper.DownloadFile($"/{post.EventID}/{post.GuestID}/{_media.Path}", $"{pathSelected}/{_media.Path}");
            }

            MessageBox.Show(succeeded
                ? "Bestand is succesvol gedownload"
                : "Er is iets misgegaan met het downloaden van deze media");
        }
        public bool AddLikeToPost(Post post, Guest guest)
        {
            if (_likes.Any(x => x.Key == post.ID && x.Value == guest.ID)) return false;

            _likes.Add(new KeyValuePair<int, int>(post.ID, guest.ID));
            return true;
        }
Пример #3
0
        /// <summary>
        /// Creates a post adds it to database
        /// </summary>
        private void btPostAanmaken_Click(object sender, EventArgs e)
        {
            // Check if message is empty
            if (string.IsNullOrEmpty(tbBerichtPost.Text))
            {
                MessageBox.Show("Ga je echt niets vertellen?");
            }
            else
            {
                // Check if chosen file is uploaded
                if (!string.IsNullOrEmpty(_uploadedMedia.Filepath) && (_uploadedMedia.UploadedFile == null))
                {
                    MessageBox.Show("Eerst uploaden voor het posten.");
                }
                else
                {
                    Post addedPost = null;
                    if (string.IsNullOrEmpty(_uploadedMedia.Filepath))
                    {
                        var media = (Media)cmbOwnMedia.SelectedItem;
                        Post p;
                        if (media == null)
                        {
                            // Post without media
                            p = new Post(0, _user.ID, _event.ID, 0, DateTime.Now, true, tbBerichtPost.Text);
                        }
                        else
                        {
                            p = new Post(0, _user.ID, _event.ID, media.ID, DateTime.Now, true, tbBerichtPost.Text);
                        }
                        addedPost = _logicPost.InsertPost(p);

                    }
                    else if(!string.IsNullOrEmpty(_uploadedMedia.Filepath))
                    {
                        // Post with media
                        if (_uploadedMedia.UploadedFile != null)
                        {
                            addedPost = _logicPost.InsertPost(new Post(0, _user.ID, _event.ID, _uploadedMedia.UploadedFile.ID, DateTime.Now, true, tbBerichtPost.Text));
                        }
                    }

                    // List of tags
                    if (addedPost != null)
                    {
                        foreach (var tag in addedPost.Tags)
                        {
                            _logicPost.AddTagToPost(addedPost, tag.ToLower());
                        }
                        MessageBox.Show("Je bericht is gepubliceerd op je tijdlijn");
                    }
                    else
                    {
                        MessageBox.Show("Je bericht is niet gepubliceerd op de tijdlijn");
                    }

                }
            }
        }
Пример #4
0
        public bool CheckReportStatus(Post post)
        {
            var allReportsByPost = LogicCollection.PostLogic.GetReportsByPost(post);
            if (allReportsByPost.Count < 5) return false;

            post.Visible = false;
            LogicCollection.PostLogic.UpdatePost(post);
            return true;
        }
        public bool Delete(Post entity)
        {
            var post = _posts.FirstOrDefault(e => e.ID == entity.ID);
            if (post == null) return false;

            _posts.Remove(post);
            _posts.Add(entity);
            return true;
        }
Пример #6
0
        public PostFeedExtended(Post post, Event ev, User admin)
        {
            InitializeComponent();
            _logicPost = new PostLogic();
            _reportContext = new ReportOracleContext();

            _post = post;
            _event = ev;
            _admin = admin;
        }
        public PostFeedExtended(Post post, Event ev, User user)
        {
            InitializeComponent();
            _logicPost = new PostLogic();
            _reportContext = new ReportOracleContext();

            _post = post;
            _event = ev;

            _activeUser = user;
        }
Пример #8
0
        public PostFeedExtended(Post post, Event ev, Guest active)
        {
            InitializeComponent();
            _logicPost = new PostLogic();
            _reportContext = new ReportOracleContext();

            _post = post;
            _event = ev;

            // Currently signed in guest
            _activeUser = active;
        }
Пример #9
0
        public PostFeed(Post post, Event ev, User user, bool reply)
        {
            InitializeComponent();

            Post = post;
            _event = ev;

            lbReaction.Visible = !reply;

            // Currently signed in user
            _activeUser = user;

            // Guest of the post
            _postUser = LogicCollection.UserLogic.GetById(Post.GuestID);
        }
Пример #10
0
        /// <summary>
        /// This method is use to load image from FTP server
        /// </summary>
        /// <param name="post">The post to look up the media of</param>
        private void ShowMedia(Post post)
        {
            if (post.MediaID != 0)
            {
                _media = LogicCollection.MediaLogic.GetById(post.MediaID);
                switch (_media.Type)
                {
                    case MediaType.Image:
                        var ftpPath = $"/{post.EventID}/{post.GuestID}/{_media.Path}";
                        pbMediaMessage.ImageLocation = $"{FtpHelper.ServerHardLogin}/{ftpPath}";
                        break;
                    case MediaType.Audio:
                        // Show mp3 icon
                        pbMediaMessage.Image = Properties.Resources.mp3;
                        break;
                    default:
                        // Show mp4 icon
                        pbMediaMessage.Image = Properties.Resources.mp4;
                        break;
                }
            }
            else
            {
                // Post doesn't have any attached media
                pbMediaMessage.Visible = false;
                lblDownloadMedia.Visible = false;

                tbMessage.Width = 614;

                lblLikeStatus.Location = new Point(545, lblLikeStatus.Location.Y);
                lbLike.Location = new Point(560, lbLike.Location.Y);

                lblDeletePost.Location = new Point(481, lblDeletePost.Location.Y);
                lbReport.Location = new Point(481, lbReport.Location.Y);

                lbReaction.Location = new Point(420, lbReaction.Location.Y);
            }
        }
Пример #11
0
 private void WatchPost(Post post)
 {
     var listOfReports = LogicCollection.PostLogic.GetReportsByPost(post);
     if (listOfReports.Count >= 1)
     {
         var rep = string.Empty;
         for (var i = 0; i < listOfReports.Count; i++)
         {
             rep += $"Report {i + 1}: {listOfReports[i].Reason}\r\n";
         }
         MessageBox.Show($"Inhoud bericht:\r\n{post.Content}\r\nDatum: {post.Date.ToString("dd MMMM yyyy")}\r\nGuestID: {post.GuestID}\r\n\r\n{rep}");
     }
     else
     {
         MessageBox.Show($"{post.Content}\r\nDatum: {post.Date.ToString("dd MMMM yyyy")}\r\nGuestID: {post.GuestID}");
     }
 }
Пример #12
0
 public Post InsertPost(Post post)
 {
     return _context.Insert(post);
 }
Пример #13
0
 public List<Report> GetReportsByPost(Post post)
 {
     return _reportContext.GetAllByPost(post);
 }
Пример #14
0
 public List<Reply> GetRepliesByPost(Post post)
 {
     return _context.GetRepliesByPost(post);
 }
Пример #15
0
 /// <summary>
 /// Adds a like to the a post
 /// </summary>
 /// <param name="guest">Guest that liked the post</param>
 /// <param name="post">Post that got liked</param>
 /// <returns>true if succesfull</returns>
 public bool Like(Guest guest, Post post)
 {
     return _context.AddLikeToPost(post, guest.ID);
 }
 public List<int> GetAllLikes(Post post)
 {
     return _likes.Where(x => x.Key == post.ID).Select(y=> y.Value).ToList();
 }
 public List<string> GetTagsByPost(Post post)
 {
     throw new NotImplementedException();
 }
Пример #18
0
 /// <summary>
 /// Adds a like to the a post
 /// </summary>
 /// <param name="admin">Guest that liked the post</param>
 /// <param name="post">Post that got liked</param>
 /// <returns>true if succesfull</returns>
 public bool Like(User admin, Post post)
 {
     return _context.AddLikeToPost(post, admin);
 }
Пример #19
0
 /// <summary>
 /// Removes a like from a post
 /// </summary>
 /// <param name="admin">Guest that unliked the post</param>
 /// <param name="post">Post that got unliked</param>
 /// <returns>true if succesfull</returns>
 public bool UnLike(User admin, Post post)
 {
     return _context.RemoveLikeFromPost(post, admin);
 }
Пример #20
0
 /// <summary>
 /// Removes a like from a post
 /// </summary>
 /// <param name="guest">Guest that unliked the post</param>
 /// <param name="post">Post that got unliked</param>
 /// <returns>true if succesfull</returns>
 public bool Unlike(Guest guest, Post post)
 {
     return _context.RemoveLikeFromPost(post, guest.ID);
 }
Пример #21
0
 /// <summary>
 /// Removes a like from a post
 /// </summary>
 /// <param name="userid">Guest that unliked the post</param>
 /// <param name="post">Post that got unliked</param>
 /// <returns>true if succesfull</returns>
 public bool Unlike(int userid, Post post)
 {
     return _context.RemoveLikeFromPost(post, userid);
 }
Пример #22
0
 /// <summary>
 /// Adds a report to a post
 /// </summary>
 /// <param name="guest">Guest that reported the post</param>
 /// <param name="post">Post that got reported</param>
 /// <param name="reason">Reason of guest to report the post</param>
 /// <returns>true if Report was successfully entered</returns>
 public bool Report(Guest guest, Post post, string reason)
 {
     var report = new Report(guest.ID, post.ID, reason, DateTime.Now);
     return (_reportContext.Insert(report) != null);
 }
Пример #23
0
 /// <summary>
 /// Adds a like to the a post
 /// </summary>
 /// <param name="userid">GuestID of who liked the post</param>
 /// <param name="post">Post that got liked</param>
 /// <returns>true if succesfull</returns>
 public bool Like(int userid, Post post)
 {
     return _context.AddLikeToPost(post, userid);
 }
Пример #24
0
 public bool DeletePost(Post post)
 {
     return _context.Delete(post);
 }
 public List<Reply> GetRepliesByPost(Post post)
 {
     return _replies.Where(r => r.MainPostID == post.ID).ToList();
 }
Пример #26
0
 public List<int> GetAllLikes(Post post)
 {
     return _context.GetAllLikes(post);
 }
Пример #27
0
 public bool UpdatePost(Post post)
 {
     return _context.Update(post);
 }
Пример #28
0
 private void WatchPost(Post post)
 {
     MessageBox.Show($"Content: {post.Content} | Datum: {post.Date.ToString("yyyy MMMM dd")} | GuestID: {post.GuestID}");
 }
Пример #29
0
 private void CheckReportStatus(Post post, PostLogic postLogic, ReportOracleContext reportContext)
 {
     var allReports = reportContext.GetAllByPost(post);
     if (allReports.Count >= 5) post.Visible = false;
     postLogic.UpdatePost(post);
 }
Пример #30
0
 public bool AddTagToPost(Post post, string tag)
 {
     return _context.AddTagToPost(post, tag);
 }