Refactoring: Added interfaces, custom exceptions, UserManager unit tests, dependency injection/inversion; Regex match search by date, keywords
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Logic;
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -43,13 +44,10 @@ namespace WinForms
|
||||
btnViewComment.Enabled = false;
|
||||
}
|
||||
|
||||
if (comment != null && currentUser != null)
|
||||
if (comment != null && currentUser != null && currentUser.ID != comment.Author.ID)
|
||||
{
|
||||
if (currentUser.ID != comment.Author.ID)
|
||||
{
|
||||
// restriction: only edit personal comments
|
||||
readOnly = true;
|
||||
}
|
||||
// restriction: only edit personal comments
|
||||
readOnly = true;
|
||||
}
|
||||
|
||||
if (readOnly)
|
||||
@@ -71,7 +69,7 @@ namespace WinForms
|
||||
}
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
CommentManager commentManager = new CommentManager();
|
||||
CommentManager commentManager = new CommentManager(new CommentRepository());
|
||||
if (string.IsNullOrEmpty(tbTitle.Text) || string.IsNullOrEmpty(tbDescription.Text))
|
||||
{
|
||||
MessageBox.Show("Please enter a title and comment text");
|
||||
@@ -135,7 +133,7 @@ namespace WinForms
|
||||
if (MessageBox.Show($"Are you sure you want to delete\n{currentResponse.Title}\nCreated at {currentResponse.PublishDate.ToString("g")} by {currentResponse.Author.Name}",
|
||||
"Delete announcement", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
CommentManager commentManager = new CommentManager();
|
||||
CommentManager commentManager = new CommentManager(new CommentRepository());
|
||||
commentManager.DeleteResponseOnComment(currentResponse.ID, comment.ID);
|
||||
}
|
||||
RefreshComments();
|
||||
|
Reference in New Issue
Block a user