﻿using System;
using System.IO;
using System.Collections.Generic;
namespace StamplingsConverter
{
    public class AWhandler
    {
        public AWhandler()
        {
        }

        public List<ResultObject> ReturnWorkDays()
        {
            var lineList = LoadData();
		
			//Make stamplingsobject and populate a list with them
			var stamplingsObjektLista = new List<ResultObject>();
            foreach (var line in lineList)
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    var columns = line.Split(';');

                    stamplingsObjektLista.Add(
                        new ResultObject
                        {

                            DateResult = DateTime.Parse(columns[1]),
                            StartTime = DateTime.Parse(columns[1] + " " + columns[2]).TimeOfDay,
                            EndTime = DateTime.Parse(columns[1] + " " + columns[3]).TimeOfDay,
                            BreakMinutes = Int32.Parse(columns[4])
                        });
                }
            }
			return stamplingsObjektLista;
        }

        private string[] LoadData()
        {
            return File.ReadAllLines("timesheet.csv");
        }
    }
}

