From fd0b6f52f2c44a1e2b443becaff21c4fe40c68be Mon Sep 17 00:00:00 2001 From: Natasa Kasikovic~ Date: Sat, 30 Mar 2024 01:33:18 +0100 Subject: [PATCH] [Add] Implementation of constructor without params --- LangLang/Core/Model/Tutor.cs | 46 +++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/LangLang/Core/Model/Tutor.cs b/LangLang/Core/Model/Tutor.cs index 4af24a89..c47a8741 100644 --- a/LangLang/Core/Model/Tutor.cs +++ b/LangLang/Core/Model/Tutor.cs @@ -5,14 +5,33 @@ using System.Linq; using System.Text; using System.Data; +using System.Reflection; namespace LangLang.Core.Model { public class Tutor : ISerializable { - private Profile _profile { get; set; } - private Dictionary _languageSkills { get; set; } - private DateTime _employmentDate { get; set; } + private Dictionary _languageSkills; + + private DateTime _employmentDate; + + private Profile _profile; + + public Dictionary LanguageSkills + { + get { return _languageSkills; } + set { _languageSkills = value; } + } + public DateTime EmploymentDate + { + get { return _employmentDate; } + set { _employmentDate = value; } + } + public Profile Profile + { + get { return _profile; } + private set { _profile = value; } + } public Tutor(int id, string name, string lastName, UserGender gender, DateTime dateOfBirth, string phoneNumber, string email, string password, UserType role, DateTime employmentDate, Dictionary languageSkills) { _profile = new Profile(id, name, lastName, gender, dateOfBirth, phoneNumber, email, password, role); @@ -20,16 +39,21 @@ public Tutor(int id, string name, string lastName, UserGender gender, DateTime d _languageSkills = languageSkills; } + public Tutor() + { + _languageSkills = new Dictionary(); + _employmentDate = DateTime.MinValue; + _profile = new(); + } + public void FromCSV(string[] values) { _profile = new Profile(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8]); - DateTime employmentDate; - if (!DateTime.TryParseExact(values[9], "yyyy-MM-dd", null, System.Globalization.DateTimeStyles.None, out employmentDate)) + if (!DateTime.TryParseExact(values[9], "yyyy-MM-dd", null, System.Globalization.DateTimeStyles.None, out _employmentDate)) { throw new FormatException("Date is not in the correct format."); } - _employmentDate = employmentDate; for (int i = 10; i < values.Length; i++) { @@ -59,16 +83,20 @@ public string[] ToCSV() return csvValues; } - public string DictToCSV(Dictionary skills){ + public string DictToCSV(Dictionary skills) + { StringBuilder sb = new StringBuilder(); var length = skills.Count(); - foreach (var skill in skills){ + foreach (var skill in skills) + { sb.Append(skill.Key).Append(",").Append(skill.Value); - if (--length>0) sb.Append("|"); + if (--length > 0) sb.Append("|"); } return sb.ToString(); } + + /* public List GetCourses(ref Dictionary courses) {