I'm starting to program in C# .NET. I've made a web calendar for workers where they can view how many days they didn't go to work due a disease, holidays, etc. At first I did it with 2 arrays. One for a full calendar with these dimensions:
calendar[person_code][month][day][6 items] -> calendar[int][int][int][object (starting absence date, type of absence, etc.)]
The other one is an array with one worker definition like
person[person_code][13 items] -> person[int][13 string (name, surname, etc.)]
I'd like to do this with classes to improve my code. I've thinking about the classes above:
public class absence
{
public int absenceCode { get; set; }
public int typeAbsence { get; set; }
public DateTime startingDate { get; set; }
public DateTime endingDate { get; set; }
public string description { get; set; }
public string state { get; set; }
public constructors...
}
public class calendar
{
public int day { get; set; }
public int month { get; set; }
public absence absen { get; set; }
public contructors....
}
public class person
{
public int personCode { get; set; }
public string surname { get; set; }
public string name { get; set; }
public string address { get; set; }
public int maxHolidayDays { get; set; }
public calendar calend { get; set; }
public constructors....
}
That is my code but I don't know how to handle to set and retrieve information like working with arrays. I can create a new instance of person for each one but I'd need to create some absences in a unique day. (One worker could absent from work some times in a day) I had though about using a List(T) class like
List<person> = new List<person>(), and List<absence> = new List<absence>()
but how could I set a List<absence>()
nested in a one day of "calendar" class?
I need to set that List inside a calendar day which has below a person from a List.
List<person> -> calendar -> List<absence>
I hope it's enough clear for you. Regards.