group and subgroup adding/editing, services added

This commit is contained in:
2023-03-26 23:01:58 +02:00
Unverified
parent 3cc4ea5b4b
commit 6e34ed1ee7
70 changed files with 2310 additions and 853 deletions

View File

@@ -11,10 +11,23 @@ namespace TimetableDesigner.Core
#region PROPERTIES
public string Name { get; set; }
public string Description { get; set; }
public Teacher Teacher { get; set; }
public Subgroup Subgroup { get; set; }
public Classroom Classroom { get; set; }
public Teacher? Teacher { get; set; }
public IGroup? Group { get; set; }
public Classroom? Classroom { get; set; }
#endregion
#region CONSTRUCTORS
public Class()
{
Name = string.Empty;
Teacher = null;
Group = null;
Classroom = null;
}
#endregion
}

View File

@@ -6,15 +6,27 @@ using System.Threading.Tasks;
namespace TimetableDesigner.Core
{
public class Group
public class Group : IGroup
{
#region PROPERTIES
public string Name { get; set; }
public string Description { get; set; }
public Subgroup MainSubgroup { get; set; }
public ICollection<Subgroup> AssignedSubgroups { get; set; }
#endregion
#region CONSTRUCTORS
public Group()
{
Name = string.Empty;
Description = string.Empty;
AssignedSubgroups = new HashSet<Subgroup>();
}
#endregion
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TimetableDesigner.Core
{
public interface IGroup
{
#region PROPERTIES
string Name { get; }
#endregion
}
}

View File

@@ -33,8 +33,10 @@ namespace TimetableDesigner.Core
Author = string.Empty;
Description = string.Empty;
TimetableTemplate = new TimetableTemplate();
Classrooms = new List<Classroom>();
Teachers = new List<Teacher>();
Classrooms = new HashSet<Classroom>();
Teachers = new HashSet<Teacher>();
Groups = new HashSet<Group>();
Subgroups = new HashSet<Subgroup>();
}
#endregion

View File

@@ -6,12 +6,22 @@ using System.Threading.Tasks;
namespace TimetableDesigner.Core
{
public class Subgroup
public class Subgroup : IGroup
{
#region PROPERTIES
public string Name { get; set; }
public string Description { get; set; }
#endregion
#region CONSTRUCTORS
public Subgroup()
{
Name = string.Empty;
}
#endregion
}

View File

@@ -33,29 +33,29 @@ namespace TimetableDesigner.Core
#region PUBLIC METHODS
internal TimetableSpansCollision CheckCollision(TimetableSpan slot)
internal TimetableSpanCollision CheckCollision(TimetableSpan slot)
{
if (slot.To <= this.From)
{
return TimetableSpansCollision.CheckedSlotBefore;
return TimetableSpanCollision.CheckedSlotBefore;
}
else if (this.To <= slot.From)
{
return TimetableSpansCollision.CheckedSlotAfter;
return TimetableSpanCollision.CheckedSlotAfter;
}
else
{
if (this.From < slot.From && slot.To < this.To)
{
return TimetableSpansCollision.CheckedSlotIn;
return TimetableSpanCollision.CheckedSlotIn;
}
else if (this.From < slot.From && slot.From < this.To && this.To < slot.To)
{
return TimetableSpansCollision.CheckedSlotFromIn;
return TimetableSpanCollision.CheckedSlotFromIn;
}
else if (slot.From < this.From && this.From < slot.To && slot.To < this.To)
{
return TimetableSpansCollision.CheckedSlotToIn;
return TimetableSpanCollision.CheckedSlotToIn;
}
else
{

View File

@@ -49,8 +49,8 @@ namespace TimetableDesigner.Core
{
switch (item.CheckCollision(_list.ElementAt(i)))
{
case TimetableSpansCollision.CheckedSlotBefore: i++; break;
case TimetableSpansCollision.CheckedSlotAfter: done ^= true; break;
case TimetableSpanCollision.CheckedSlotBefore: i++; break;
case TimetableSpanCollision.CheckedSlotAfter: done ^= true; break;
default: throw new ArgumentException("Slot collide with another slot");
}
}

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace TimetableDesigner.Core
{
internal enum TimetableSpansCollision
internal enum TimetableSpanCollision
{
CheckedSlotBefore,
CheckedSlotAfter,