Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified NoSQLSolution/.vs/NoSQLSolution/v17/.suo
Binary file not shown.
9 changes: 9 additions & 0 deletions NoSQLSolution/DAL/EmployeeDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,14 @@ public List<Employee> GetAllRegularUsers()
var filter = Builders<Employee>.Filter.Eq("UserType", UserType.RegularUser);
return database.GetCollection<Employee>("Employees").Find(filter).ToList();
}
public void Insert(Employee employee)
{
database.GetCollection<Employee>("Employees").InsertOne(employee);
}

public Employee Get(ObjectId id)
{
return database.GetCollection<Employee>("Employees").Find<Employee>(employee => employee._id == id).FirstOrDefault();
}
}
}
9 changes: 8 additions & 1 deletion NoSQLSolution/DAL/TicketsDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public TicketsDao()

public List<Ticket> GetAllTickets()
{
FilterDefinition<Ticket> filter = Builders<Ticket>.Filter.Gt("Priority", TicketPriority.Closed); // Only check for tickets that are relevant
var filter = Builders<Ticket>.Filter.Ne(t => t.Priority, TicketPriority.Closed);
return ticketCollection.Find(filter).ToList();
}

Expand Down Expand Up @@ -49,5 +49,12 @@ public void updateTicket(Ticket ticket)
if (!ticketCollection.UpdateOne(filter, update).IsAcknowledged)
throw new Exception("Ticket could not be updated");
}
public void CloseTicket(int ticketId)
{
var filter = Builders<Ticket>.Filter.Eq(t => t.TicketId, ticketId);
var update = Builders<Ticket>.Update.Set(t => t.Priority, TicketPriority.Closed);
ticketCollection.UpdateOne(filter, update);
}

}
}
Binary file modified NoSQLSolution/DAL/bin/Debug/DAL.dll
Binary file not shown.
Binary file modified NoSQLSolution/DAL/bin/Debug/DAL.pdb
Binary file not shown.
Binary file modified NoSQLSolution/DAL/bin/Debug/Model.dll
Binary file not shown.
Binary file modified NoSQLSolution/DAL/bin/Debug/Model.pdb
Binary file not shown.
Binary file modified NoSQLSolution/DAL/obj/Debug/DAL.csproj.AssemblyReference.cache
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bd96249f908118f60dc0685b102b566ec5cb27c0
ff1149b5bc7fee515a1a04966ebe3b009300a7d9
29 changes: 29 additions & 0 deletions NoSQLSolution/DAL/obj/Debug/DAL.csproj.FileListAbsolute.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,32 @@ C:\Users\coen\OneDrive - Hogeschool Inholland\Laptop\Documenten\School\Project N
C:\Users\coen\OneDrive - Hogeschool Inholland\Laptop\Documenten\School\Project NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.csproj.CopyComplete
C:\Users\coen\OneDrive - Hogeschool Inholland\Laptop\Documenten\School\Project NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.dll
C:\Users\coen\OneDrive - Hogeschool Inholland\Laptop\Documenten\School\Project NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.pdb
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\snappy32.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\snappy64.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\libzstd.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\mongocrypt.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\DAL.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\DAL.pdb
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\DnsClient.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\Model.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Bson.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Driver.Core.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Driver.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Libmongocrypt.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\SharpCompress.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\System.Buffers.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\System.Runtime.CompilerServices.Unsafe.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\System.ValueTuple.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\Model.pdb
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\DnsClient.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Bson.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Driver.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\MongoDB.Driver.Core.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\System.Buffers.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\System.Runtime.CompilerServices.Unsafe.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\bin\Debug\System.ValueTuple.xml
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.csproj.AssemblyReference.cache
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.csproj.CoreCompileInputs.cache
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.csproj.CopyComplete
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.dll
C:\Users\selim\source\Project NoSQL\Project-NoSQL\NoSQLSolution\DAL\obj\Debug\DAL.pdb
Binary file modified NoSQLSolution/DAL/obj/Debug/DAL.dll
Binary file not shown.
Binary file modified NoSQLSolution/DAL/obj/Debug/DAL.pdb
Binary file not shown.
1 change: 1 addition & 0 deletions NoSQLSolution/DemoApp/AddTicketForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected virtual void btnSubmit_Click(object sender, EventArgs e)
else
{
ticketsLogic.insertTicket(new Ticket(MongoDB.Bson.ObjectId.Empty, -1, employee._id, employee.Email, dateTimePickerTicket.Value, (TypeOfIncident)Enum.Parse(typeof(TypeOfIncident), comboBoxType.Text), (TicketPriority)Enum.Parse(typeof(TicketPriority), comboBoxPriority.Text), (Deadlines)Enum.Parse(typeof(Deadlines), comboBoxDeadline.Text), textBoxDescription.Text));
this.DialogResult = DialogResult.OK;
this.Close();
MessageBox.Show("ticket is added", "");
}
Expand Down
62 changes: 32 additions & 30 deletions NoSQLSolution/DemoApp/AddUserForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 55 additions & 8 deletions NoSQLSolution/DemoApp/AddUserForm.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,67 @@
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;
using Model;
using Logic;
using System.IO;

namespace DemoApp
{
public partial class AddUserForm : Form
{
public AddUserForm()
private EmployeeLogic employeeLogic;
private ManageUsersForm manageUsersForm;
public AddUserForm(ManageUsersForm userManagementForm)
{
InitializeComponent();
this.manageUsersForm = userManagementForm;
employeeLogic = new EmployeeLogic();
cbUserType.DataSource = Enum.GetValues(typeof(UserType));
cbLocationBranch.DataSource = Enum.GetValues(typeof(LocationBranch));
}
public void btnSubmit_Click(object sender, EventArgs e)
{
string password = GenerateRandomPassword();

if (string.IsNullOrWhiteSpace(txtboxFirstName.Text) ||
string.IsNullOrWhiteSpace(txtboxLastName.Text) ||
string.IsNullOrWhiteSpace(txtboxEmail.Text) ||
string.IsNullOrWhiteSpace(txtboxPhoneNumber.Text))
{
MessageBox.Show("Please fill in all fields.");
return;
}
Employee newEmployee = new Employee
{
Firstname = txtboxFirstName.Text.Trim(),
Lastname = txtboxLastName.Text.Trim(),
Email = txtboxEmail.Text.Trim(),
Phonenumber = txtboxPhoneNumber.Text.Trim(),
UserType = (UserType)cbUserType.SelectedItem,
BranchLocation = (LocationBranch)cbLocationBranch.SelectedItem,
Password = password,
};

try
{
employeeLogic.AddEmployee(newEmployee);
manageUsersForm.AddUserToListView(newEmployee, password);
MessageBox.Show("Employee added successfully");
this.DialogResult = DialogResult.OK;
this.Close();
}
catch (Exception ex)
{
MessageBox.Show($"Error adding employee: {ex.Message}", "Error");
}
}
private string GenerateRandomPassword()
{
return Path.GetRandomFileName().Replace(".", "").Substring(0, 12);
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
}
}
29 changes: 18 additions & 11 deletions NoSQLSolution/DemoApp/ManageUsersForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading