Documentation & code cleanup
This commit is contained in:
23
README.md
23
README.md
@@ -1,5 +1,24 @@
|
||||
# Student House Dashboard
|
||||
|
||||
Work in progress
|
||||
|
||||
Project documentation is available in the docs folder
|
||||
|
||||
## Default user details
|
||||
|
||||
### System administrator
|
||||
admin
|
||||
admin
|
||||
|
||||
### Manager
|
||||
manager
|
||||
manager
|
||||
|
||||
### Tenant
|
||||
room1
|
||||
room1
|
||||
|
||||
room2
|
||||
room2
|
||||
|
||||
## FHICT Luna server
|
||||
|
||||
The web application is hosted on the FHICT Luna server at: https://i509645.luna.fhict.nl/
|
@@ -1,13 +1,8 @@
|
||||
using Models;
|
||||
using Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Logic;
|
||||
using Logic.Exceptions;
|
||||
using System.Reflection;
|
||||
using Models;
|
||||
using System.Data.SqlClient;
|
||||
using System.Text;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
@@ -50,13 +45,13 @@ namespace Data
|
||||
cmd.Parameters.AddWithValue("id", id);
|
||||
var reader = cmd.ExecuteReader();
|
||||
reader.Read();
|
||||
Announcement announcement = new Announcement(Convert.ToInt32(reader["ID"]),
|
||||
userRepository.GetUserById(Convert.ToInt32(reader["Author"])),
|
||||
reader["Description"].ToString(), reader["Title"].ToString(),
|
||||
(DateTime)reader["PublishDate"], (bool)reader["IsImportant"],
|
||||
(bool)reader["IsSticky"]);
|
||||
CommentRepository commentRepository = new CommentRepository();
|
||||
announcement.Comments = commentRepository.GetAllCommentsOnAnnouncement(announcement.ID);
|
||||
Announcement announcement = new Announcement(Convert.ToInt32(reader["ID"]),
|
||||
userRepository.GetUserById(Convert.ToInt32(reader["Author"])),
|
||||
reader["Description"].ToString(), reader["Title"].ToString(),
|
||||
(DateTime)reader["PublishDate"], (bool)reader["IsImportant"],
|
||||
(bool)reader["IsSticky"]);
|
||||
CommentRepository commentRepository = new CommentRepository();
|
||||
announcement.Comments = commentRepository.GetAllCommentsOnAnnouncement(announcement.ID);
|
||||
conn.Close();
|
||||
return announcement;
|
||||
}
|
||||
|
@@ -1,8 +1,7 @@
|
||||
using System.ComponentModel.Design;
|
||||
using System.Data.SqlClient;
|
||||
using Models;
|
||||
using Logic;
|
||||
using Logic.Exceptions;
|
||||
using Models;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Data;
|
||||
|
||||
|
@@ -1,12 +1,8 @@
|
||||
using Logic;
|
||||
using Logic.Exceptions;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
@@ -14,7 +10,7 @@ namespace Data
|
||||
{
|
||||
public ComplaintRepository()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public List<Complaint> GetAllComplaints()
|
||||
{
|
||||
@@ -86,7 +82,7 @@ namespace Data
|
||||
}
|
||||
using (SqlConnection conn = SqlConnectionHelper.CreateConnection())
|
||||
{
|
||||
|
||||
|
||||
SqlCommand sqlCommand = new SqlCommand(sql, conn);
|
||||
sqlCommand.Parameters.AddWithValue("@start", p * c);
|
||||
sqlCommand.Parameters.AddWithValue("@count", c);
|
||||
|
@@ -1,12 +1,7 @@
|
||||
using Logic;
|
||||
using Logic.Exceptions;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
|
@@ -1,10 +1,5 @@
|
||||
using Logic.Exceptions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
|
@@ -1,13 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Data.SqlClient;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System.Data;
|
||||
using System.Xml.Linq;
|
||||
using Logic;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace Data
|
||||
{
|
||||
@@ -115,7 +108,7 @@ namespace Data
|
||||
}
|
||||
}
|
||||
|
||||
public User GetUserByName(string userName)
|
||||
public User? GetUserByName(string userName)
|
||||
{
|
||||
using (SqlConnection conn = SqlConnectionHelper.CreateConnection())
|
||||
{
|
||||
@@ -124,8 +117,14 @@ namespace Data
|
||||
cmd.Parameters.AddWithValue("@userName", userName);
|
||||
var reader = cmd.ExecuteReader();
|
||||
|
||||
return new User(Convert.ToInt32(reader["ID"]), reader["Name"].ToString(),
|
||||
if (reader.HasRows)
|
||||
{
|
||||
reader.Read();
|
||||
return new User(Convert.ToInt32(reader["ID"]), reader["Name"].ToString(),
|
||||
reader["Password"].ToString(), (UserRole)reader["Role"]);
|
||||
}
|
||||
else { return null; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,5 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
@@ -14,7 +9,7 @@ namespace Logic
|
||||
{
|
||||
this.commentRepository = commentRepository;
|
||||
}
|
||||
|
||||
|
||||
public Comment GetCommentById(int id)
|
||||
{
|
||||
return commentRepository.GetCommentById(id);
|
||||
|
@@ -1,16 +1,11 @@
|
||||
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)
|
||||
public ComplaintManager(IComplaintRepository complaintRepository)
|
||||
{
|
||||
this.complaintRepository = complaintRepository;
|
||||
}
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
@@ -14,7 +9,7 @@ namespace Logic
|
||||
{
|
||||
this.eventRepository = eventRepository;
|
||||
}
|
||||
public List<Event> GetAllEvents()
|
||||
public List<Event> GetAllEvents()
|
||||
{
|
||||
return eventRepository.GetAllEvents();
|
||||
}
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
|
||||
namespace Logic.Exceptions
|
||||
{
|
||||
|
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic.Exceptions
|
||||
namespace Logic.Exceptions
|
||||
{
|
||||
public class DatabaseOperationException : ApplicationException
|
||||
{
|
||||
|
@@ -1,10 +1,4 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
|
@@ -1,5 +1,3 @@
|
||||
using System.ComponentModel.Design;
|
||||
using System.Data.SqlClient;
|
||||
using Models;
|
||||
|
||||
namespace Logic;
|
||||
|
@@ -1,10 +1,4 @@
|
||||
using Logic.Exceptions;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Models;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
@@ -17,4 +12,3 @@ namespace Logic
|
||||
public void DeleteEvent(int id);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
|
@@ -1,14 +1,4 @@
|
||||
using BCrypt.Net;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using Models;
|
||||
|
||||
namespace Logic
|
||||
{
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Models
|
||||
namespace Models
|
||||
{
|
||||
public class Announcement : GenericMessage
|
||||
{
|
||||
@@ -15,16 +10,16 @@ namespace Models
|
||||
|
||||
public Announcement()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public List<Comment> Comments
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool IsImportant
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public bool IsSticky
|
||||
|
@@ -1,21 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Models
|
||||
namespace Models
|
||||
{
|
||||
public class Comment : GenericMessage
|
||||
{
|
||||
public Comment()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public Comment(int id, User author, string description, string title, DateTime publishDate) : base(id, author, description, title, publishDate)
|
||||
{
|
||||
Responses = new List<Comment>();
|
||||
}
|
||||
|
||||
|
||||
public List<Comment> Responses { get; set; }
|
||||
public override string ToString()
|
||||
{
|
||||
|
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Models
|
||||
namespace Models
|
||||
{
|
||||
public class Complaint : GenericMessage
|
||||
{
|
||||
public Complaint()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public Complaint(int id, User author, string description, string title, DateTime publishDate, ComplaintStatus status, ComplaintSeverity severity) : base(id, author, description, title, publishDate)
|
||||
{
|
||||
@@ -19,17 +14,17 @@ namespace Models
|
||||
|
||||
public ComplaintStatus Status
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public ComplaintSeverity Severity
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public List<Comment> Responses
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Models
|
||||
{
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Models
|
||||
{
|
||||
|
@@ -1,15 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Models
|
||||
namespace Models
|
||||
{
|
||||
public class Event : GenericMessage
|
||||
{
|
||||
public Event()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public Event(int id, User author, string description, string title, DateTime publishDate, DateTime startDate, DateTime endDate) : base(id, author, description, title, publishDate)
|
||||
{
|
||||
@@ -19,12 +14,12 @@ namespace Models
|
||||
|
||||
public DateTime StartDate
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
|
||||
public DateTime EndDate
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
|
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Models
|
||||
{
|
||||
@@ -18,7 +14,7 @@ namespace Models
|
||||
}
|
||||
protected GenericMessage()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public int ID
|
||||
{
|
||||
@@ -27,16 +23,16 @@ namespace Models
|
||||
|
||||
public User Author
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
public string Description
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
[StringLength(255)]
|
||||
public string Title
|
||||
{
|
||||
get;set;
|
||||
get; set;
|
||||
}
|
||||
public DateTime PublishDate
|
||||
{
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Models
|
||||
{
|
||||
@@ -25,13 +20,17 @@ namespace Models
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Required]
|
||||
[StringLength(255)]
|
||||
public string Name
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
[Required]
|
||||
[DataType(DataType.Password)]
|
||||
[StringLength(int.MaxValue, MinimumLength = 4)]
|
||||
public string Password
|
||||
{
|
||||
get; set;
|
||||
|
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Models
|
||||
{
|
||||
|
@@ -1,10 +1,5 @@
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tests.Mocks;
|
||||
|
||||
namespace Tests
|
||||
|
@@ -1,13 +1,6 @@
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Tests.Mocks
|
||||
{
|
||||
@@ -16,7 +9,7 @@ namespace Tests.Mocks
|
||||
private List<Announcement> announcements;
|
||||
private int currentId;
|
||||
|
||||
public AnnouncementRepositoryFake()
|
||||
public AnnouncementRepositoryFake()
|
||||
{
|
||||
announcements = new List<Announcement>();
|
||||
currentId = 1;
|
||||
|
@@ -1,10 +1,5 @@
|
||||
using Models;
|
||||
using Logic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Logic;
|
||||
using Models;
|
||||
|
||||
namespace Tests.Mocks
|
||||
{
|
||||
@@ -12,7 +7,7 @@ namespace Tests.Mocks
|
||||
{
|
||||
private List<User> users;
|
||||
private int currentId;
|
||||
public UserRepositoryFake()
|
||||
public UserRepositoryFake()
|
||||
{
|
||||
users = new List<User>();
|
||||
currentId = 1;
|
||||
|
@@ -1,4 +1,3 @@
|
||||
using BCrypt.Net;
|
||||
using Logic;
|
||||
using Models;
|
||||
using Tests.Mocks;
|
||||
@@ -26,7 +25,7 @@ namespace Tests
|
||||
// Assert
|
||||
Assert.IsNull(result);
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void AuthenticatedUserNullPasswordTest()
|
||||
@@ -133,7 +132,7 @@ namespace Tests
|
||||
// Assert
|
||||
// ArgumentException expected
|
||||
}
|
||||
|
||||
|
||||
[TestMethod]
|
||||
public void DisableUserTest()
|
||||
{
|
||||
@@ -148,6 +147,6 @@ namespace Tests
|
||||
Assert.AreEqual(user.Name, $"Deleted User {user.ID}");
|
||||
Assert.AreEqual(user.Password, "0");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
using Logic;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Models;
|
||||
|
@@ -1,9 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Models;
|
||||
using Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,9 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Models;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,9 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Models;
|
||||
using Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,8 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Models;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using System.Security.Claims;
|
||||
|
||||
namespace WebApp.Pages
|
||||
|
@@ -24,7 +24,7 @@ namespace WebApp.Pages
|
||||
if (id != null)
|
||||
{
|
||||
Announcement announcement = announcementManager.GetAnnouncementById(id);
|
||||
if (announcement.Author.ID == int.Parse(User.FindFirstValue("id")) || User.IsInRole("ADMIN") )
|
||||
if (announcement.Author.ID == int.Parse(User.FindFirstValue("id")) || User.IsInRole("ADMIN"))
|
||||
{
|
||||
ViewData["announcement"] = announcement;
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ namespace WebApp.Pages
|
||||
if (id != null)
|
||||
{
|
||||
Event @event = eventManager.GetEventById(id.Value);
|
||||
if (@event.Author.ID == int.Parse(User.FindFirstValue("id")) || User.IsInRole("ADMIN") )
|
||||
if (@event.Author.ID == int.Parse(User.FindFirstValue("id")) || User.IsInRole("ADMIN"))
|
||||
{
|
||||
ViewData["event"] = @event;
|
||||
}
|
||||
@@ -46,7 +46,7 @@ namespace WebApp.Pages
|
||||
EventManager eventManager = new EventManager(_eventRepository);
|
||||
eventManager.UpdateEvent(Event.ID, Event.Title, Event.Description, Event.StartDate, Event.EndDate);
|
||||
}
|
||||
|
||||
|
||||
return RedirectToPage("Events");
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,3 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages.Error
|
||||
|
@@ -1,4 +1,3 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages.Error
|
||||
|
@@ -1,9 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Models;
|
||||
using Data;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,10 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System.Security.Claims;
|
||||
using System.Dynamic;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,6 +1,4 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,11 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Data;
|
||||
using Logic;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Models;
|
||||
using Logic;
|
||||
using System.Security.Claims;
|
||||
using Data;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Logic;
|
||||
using Models;
|
||||
using Data;
|
||||
|
||||
namespace WebApp.Pages
|
||||
{
|
||||
@@ -16,9 +16,21 @@ namespace WebApp.Pages
|
||||
public void OnPost()
|
||||
{
|
||||
var userManager = new UserManager(new UserRepository());
|
||||
if (userManager.CreateUser(MyUser.Name, BCrypt.Net.BCrypt.HashPassword(MyUser.Password), MyUser.Role) != null)
|
||||
User? result = null;
|
||||
try
|
||||
{
|
||||
ViewData["confirm"] = $"Successfully registered {MyUser.Name}!";
|
||||
result = userManager.CreateUser(MyUser.Name, BCrypt.Net.BCrypt.HashPassword(MyUser.Password), MyUser.Role);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
ViewData["confirm"] = "An error has occurred. Try a different username.";
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (result != null)
|
||||
{
|
||||
ViewData["confirm"] = $"Successfully registered {MyUser.Name}!";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,8 @@ namespace WebApp
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorPages();
|
||||
|
||||
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => {
|
||||
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options =>
|
||||
{
|
||||
options.LoginPath = new PathString("/Login");
|
||||
options.AccessDeniedPath = new PathString("/Error/401");
|
||||
});
|
||||
|
@@ -1,15 +1,6 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
|
@@ -1,15 +1,6 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
@@ -80,11 +71,11 @@ namespace WinForms
|
||||
{
|
||||
switch (responseType)
|
||||
{
|
||||
case "announcement":
|
||||
commentManager.CreateCommentOnAnnouncement(currentUser, tbDescription.Text, tbTitle.Text, dtpPublishDate.Value, parentId);
|
||||
case "announcement":
|
||||
commentManager.CreateCommentOnAnnouncement(currentUser, tbDescription.Text, tbTitle.Text, dtpPublishDate.Value, parentId);
|
||||
break;
|
||||
case "comment":
|
||||
commentManager.CreateResponseOnComment(currentUser, tbDescription.Text, tbTitle.Text, dtpPublishDate.Value, parentId);
|
||||
case "comment":
|
||||
commentManager.CreateResponseOnComment(currentUser, tbDescription.Text, tbTitle.Text, dtpPublishDate.Value, parentId);
|
||||
break;
|
||||
case "complaint":
|
||||
commentManager.CreateCommentOnComplaint(currentUser, tbDescription.Text, tbTitle.Text, dtpPublishDate.Value, parentId);
|
||||
@@ -111,7 +102,7 @@ namespace WinForms
|
||||
form.ShowDialog();
|
||||
RefreshComments();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void btnEditComment_Click(object sender, EventArgs e)
|
||||
|
@@ -1,15 +1,6 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
|
@@ -1,15 +1,6 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
|
@@ -1,15 +1,6 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
|
@@ -1,15 +1,6 @@
|
||||
using Data;
|
||||
using Logic;
|
||||
using Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinForms
|
||||
{
|
||||
|
BIN
docs/project-report.docx
Normal file
BIN
docs/project-report.docx
Normal file
Binary file not shown.
Binary file not shown.
BIN
docs/testplan.pdf
Normal file
BIN
docs/testplan.pdf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
USE dbi509645
|
||||
GO
|
||||
|
||||
-- User roles
|
||||
INSERT INTO UserRole ([Role])
|
||||
VALUES
|
||||
('TENANT'),
|
||||
@@ -8,6 +9,7 @@ VALUES
|
||||
('ADMIN')
|
||||
GO
|
||||
|
||||
-- Default users
|
||||
INSERT INTO Users ([Name], [Password], [Role])
|
||||
VALUES
|
||||
('admin', 'admin', 2),
|
||||
@@ -15,6 +17,7 @@ VALUES
|
||||
('room1', 'room1', 0)
|
||||
GO
|
||||
|
||||
-- Complaint status
|
||||
INSERT INTO ComplaintStatus ([Status])
|
||||
VALUES
|
||||
('FILED'),
|
||||
@@ -23,12 +26,11 @@ VALUES
|
||||
('ARCHIVED')
|
||||
GO
|
||||
|
||||
-- Complaint severity
|
||||
INSERT INTO ComplaintSeverity ([Severity])
|
||||
VALUES
|
||||
('LOW'),
|
||||
('NORMAL'),
|
||||
('HIGH'),
|
||||
('URGENT')
|
||||
GO
|
||||
|
||||
SELECT * FROM Users u JOIN UserRole r ON u.[Role] = r.ID
|
||||
GO
|
@@ -15,6 +15,8 @@ CREATE TABLE Users (
|
||||
)
|
||||
GO
|
||||
|
||||
-- Used only in previous versions for a contact form
|
||||
-- no longer needed
|
||||
CREATE TABLE ContactForm (
|
||||
ID INT PRIMARY KEY IDENTITY NOT NULL,
|
||||
[Name] NVARCHAR(255) NOT NULL,
|
Reference in New Issue
Block a user