Ejemplo n.º 1
0
        public IEnumerable <SeatChange> GenerateDiff(string filepathA, string filepathB)
        {
            if (String.IsNullOrWhiteSpace(filepathA) || !File.Exists(filepathA))
            {
                throw new ArgumentException("Invalid filepath", "filepathA");
            }
            if (String.IsNullOrWhiteSpace(filepathB) || !File.Exists(filepathB))
            {
                throw new ArgumentException("Invalid filepath", "filepathB");
            }

            var fileA = BillettServiceXmlFile.LoadFile(filepathA);
            var fileB = BillettServiceXmlFile.LoadFile(filepathB);

            var seatReader = new BillettServiceSeteLeser();

            var seatsA = seatReader.ReadSeats(fileA).ToList();
            var seatsB = seatReader.ReadSeats(fileB).ToList();

            var joinQuery = from seatA in seatsA
                            join seatB in seatsB
                            on new { seatA.SectionName, seatA.RowName, seatA.SeatName }
            equals new { seatB.SectionName, seatB.RowName, seatB.SeatName }
            select new SeatChange(seatA, seatB);
            var diff = joinQuery.Where(sc => sc.FromEtt != sc.ToEtt)
                       .OrderBy(s => s.ToString())
                       .ToList();

            return(diff);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Lag en oppsummering av salgsstatus fra en XML-fil
        /// </summary>
        /// <param name="ticketFile">Fila vi skal lese fra</param>
        /// <returns>En dictionary med setestatus og antall seter</returns>
        public IDictionary <SeatStatus, int> CreateSummary(BillettServiceXmlFile ticketFile)
        {
            var leser = new BillettServiceSeteLeser();
            var stats = leser.ReadSeatSummary(ticketFile)
                        .Select(s => new { Code = SeatStatusClassifier.Classify(s.EttCode), Seats = s.Count })
                        .GroupBy(s => s.Code)
                        .Select(g => new { Status = g.Key, Count = g.Sum(f => f.Seats) })
                        .OrderByDescending(g => g.Count)
                        .ToDictionary(arg => arg.Status, arg => arg.Count);

            return(stats);
        }