/// <summary> /// Copy constructor for WorkingYearBase /// </summary> /// <param name="year">Year to copy</param> protected WorkingYearBase(IWorkingYear year) { YearCount = year.YearCount; CalenderDays = year.CalenderDays; WeekendDays = year.WeekendDays; PublicHolidays = year.PublicHolidays; PrivateHolidays = year.PrivateHolidays; SickDays = year.SickDays; QualificationDays = year.QualificationDays; ProuctivityFactor = year.ProuctivityFactor; }
/// <summary> /// Adds a working year to serialized data /// </summary> /// <param name="item">Item to add</param> /// <param name="fileFormat"> <see cref="OwlSerializer.FileFormats"/> of the item</param> /// <returns>Id of item</returns> public int AddWorkingYear(IWorkingYear item, OwlSerializer.FileFormats fileFormat) { if (!yearsCollection.ContainsKey(item.YearCount)) { WorkingYear year = new WorkingYear(item); switch (fileFormat) { case OwlSerializer.FileFormats.Cfg: case OwlSerializer.FileFormats.Xml: OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount, OwlSerializer.FileFormats.Xml); break; case OwlSerializer.FileFormats.Json: OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount, OwlSerializer.FileFormats.Json); break; } yearsCollection.Add(year.YearCount,year); return year.YearCount; } return -1; }
/// <summary> /// Updates the given item /// </summary> /// <param name="item">Item to update</param> /// <param name="fileFormat"> <see cref="OwlSerializer.FileFormats"/> of the item</param> public bool UpdateWorkingYear(IWorkingYear item, OwlSerializer.FileFormats fileFormat) { WorkingYear year = new WorkingYear(item); if (yearsCollection.ContainsKey(year.YearCount)) { yearsCollection[year.YearCount] = year; switch (fileFormat) { case OwlSerializer.FileFormats.Cfg: case OwlSerializer.FileFormats.Xml: OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount, OwlSerializer.FileFormats.Xml); break; case OwlSerializer.FileFormats.Json: OwlSerializer.Save(year, typeof(WorkingYear), yearFolder + year.YearCount, OwlSerializer.FileFormats.Json); break; } return true; } return false; }
/// <summary> /// Removes a working year from serialized data /// </summary> /// <param name="item">Item to remove</param> /// <param name="fileFormat"> <see cref="OwlSerializer.FileFormats"/> of the item</param> public bool RemoveWorkingYear(IWorkingYear item, OwlSerializer.FileFormats fileFormat) { if (yearsCollection.ContainsKey(item.YearCount)) { OwlSerializer.Delete(yearFolder + item.YearCount, fileFormat); yearsCollection.Remove(item.YearCount); return true; } return false; }
/// <summary> /// Checks if the item is in the database /// </summary> /// <param name="item">Item to check</param> /// <returns></returns> public bool ContainsWorkingYear(IWorkingYear item) { return yearsCollection.ContainsKey(item.YearCount); }
/// <summary> /// Copy constructor for a working year /// </summary> /// <param name="year">Working year to copy</param> public WorkingYear(IWorkingYear year) : base(year) { }