Test plan incomplete, basic compaints support
This commit is contained in:
@@ -53,13 +53,16 @@ namespace Logic
|
||||
DateTime date;
|
||||
if (DateTime.TryParse(match.Groups[0].Value, out date))
|
||||
{
|
||||
query = Regex.Replace(query, "date:[0-9]{4}-[0-9]{2}-[0-9]{2}", "");
|
||||
query = Regex.Replace(query, "date:[0-9]{4}-[0-9]{2}-[0-9]{2}", "").Trim();
|
||||
if (string.IsNullOrEmpty(query))
|
||||
{
|
||||
// search only by date
|
||||
return announcementRepository.GetAllAnnouncements().Where(x => x.PublishDate.Date == date.Date).ToList();
|
||||
}
|
||||
// search by date and keywords
|
||||
else return announcementRepository.SearchAnnouncement(query).Where(x => x.PublishDate.Date == date.Date).ToList();
|
||||
}
|
||||
// search by keywords
|
||||
else return announcementRepository.SearchAnnouncement(query);
|
||||
}
|
||||
}
|
||||
|
42
StudentHouseDashboard/Logic/ComplaintManager.cs
Normal file
42
StudentHouseDashboard/Logic/ComplaintManager.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
public class ComplaintManager
|
||||
{
|
||||
private IComplaintRepository complaintRepository;
|
||||
public ComplaintManager(IComplaintRepository complaintRepository)
|
||||
{
|
||||
this.complaintRepository = complaintRepository;
|
||||
}
|
||||
public List<Complaint> GetAllComplaints()
|
||||
{
|
||||
return complaintRepository.GetAllComplaints();
|
||||
}
|
||||
public Complaint GetComplaintById(int id)
|
||||
{
|
||||
return complaintRepository.GetComplaintById(id);
|
||||
}
|
||||
public List<Complaint> GetComplaintsByPage(int userId, int p, int c)
|
||||
{
|
||||
return complaintRepository.GetComplaintsByPage(userId, p, c);
|
||||
}
|
||||
public Complaint CreateComplaint(string title, string description, User author, DateTime publishDate, ComplaintStatus status, ComplaintSeverity severity)
|
||||
{
|
||||
return complaintRepository.CreateComplaint(title, description, author, publishDate, status, severity);
|
||||
}
|
||||
public void UpdateComplaint(int id, string title, string description, ComplaintStatus status, ComplaintSeverity severity)
|
||||
{
|
||||
complaintRepository.UpdateComplaint(id, title, description, status, severity);
|
||||
}
|
||||
public List<Complaint> SearchComplaint(string query)
|
||||
{
|
||||
return complaintRepository.SearchComplaint(query);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,11 +7,13 @@ namespace Logic;
|
||||
public interface ICommentRepository
|
||||
{
|
||||
public List<Comment> GetAllCommentsOnAnnouncement(int announcementId);
|
||||
public List<Comment> GetAllCommentsOnComplaint(int complaintId);
|
||||
public List<Comment> GetAllCommentResponses(int commentId);
|
||||
public Comment GetCommentById(int id);
|
||||
public void UpdateComment(int id, string description);
|
||||
public Comment CreateComment(User author, string description, string title, DateTime publishDate);
|
||||
public void CreateCommentOnAnnouncement(User author, string description, string title, DateTime publishDate, int announcementId);
|
||||
public void CreateCommentOnComplaint(User author, string description, string title, DateTime publishDate, int complaintId);
|
||||
public void CreateResponseOnComment(User author, string description, string title, DateTime publishDate, int commentId);
|
||||
public void DeleteComment(int id);
|
||||
public void DeleteCommentOnAnnouncement(int commentId, int announcementId);
|
||||
|
20
StudentHouseDashboard/Logic/IComplaintRepository.cs
Normal file
20
StudentHouseDashboard/Logic/IComplaintRepository.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Logic.Exceptions;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
public interface IComplaintRepository
|
||||
{
|
||||
public List<Complaint> GetAllComplaints();
|
||||
public Complaint GetComplaintById(int id);
|
||||
public List<Complaint> GetComplaintsByPage(int userId, int p, int c);
|
||||
public Complaint CreateComplaint(string title, string description, User author, DateTime publishDate, ComplaintStatus status, ComplaintSeverity severity);
|
||||
public void UpdateComplaint(int id, string title, string description, ComplaintStatus status, ComplaintSeverity severity);
|
||||
public List<Complaint> SearchComplaint(string query);
|
||||
}
|
||||
}
|
@@ -33,12 +33,12 @@ namespace Logic
|
||||
}
|
||||
public User? AuthenticatedUser(string name, string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new ArgumentException("Name or password should not be empty!");
|
||||
}
|
||||
List<User> users = userRepository.GetAllUsers();
|
||||
User? user = users.Find(x => x.Name == name);
|
||||
if (name == null || password == null)
|
||||
{
|
||||
throw new ArgumentNullException();
|
||||
}
|
||||
if (user != null && BCrypt.Net.BCrypt.Verify(password, user.Password))
|
||||
{
|
||||
return user;
|
||||
@@ -57,12 +57,16 @@ namespace Logic
|
||||
}
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new ArgumentException("Name or password should not be empty");
|
||||
throw new ArgumentException("Name or password should not be empty!");
|
||||
}
|
||||
return userRepository.CreateUser(name, password, role);
|
||||
}
|
||||
public void UpdateUser(int id, string name, string password, UserRole role)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new ArgumentException("Name or password should not be empty!");
|
||||
}
|
||||
userRepository.UpdateUser(id, name, password, role);
|
||||
}
|
||||
public void DisableUser(int id)
|
||||
|
Reference in New Issue
Block a user