Documentation & code cleanup
This commit is contained in:
@@ -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; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user