﻿using NldbApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace NldbApi.Infrastructure
{
    public static class ExtenstionMethods
    {
        public static List<DetailedCharacter> ToDetailedCharacter(this IEnumerable<Character> characters)
        {
            List<DetailedCharacter> detailedCharacterList = new List<DetailedCharacter>(characters.Count());

            foreach (Character c in characters)
            {
                detailedCharacterList.Add(new DetailedCharacter
                {
                    Character = c,
                    GraphBar = new GraphBar()
                });
            }

            return detailedCharacterList;
        }

        public static List<DetailedCurse> ToDetailedCurse(this IEnumerable<Curse> curses)
        {
            List<DetailedCurse> detailedCurseList = new List<DetailedCurse>(curses.Count());

            foreach (Curse c in curses)
            {
                detailedCurseList.Add(new DetailedCurse
                {
                    Curse = c,
                    GraphBar = new GraphBar()
                });
            }

            return detailedCurseList;
        }

        public static List<DetailedFloor> ToDetailedFloor(this IEnumerable<Floor> floors)
        {
            List<DetailedFloor> detailedFloorList = new List<DetailedFloor>(floors.Count());

            foreach (Floor f in floors)
            {
                detailedFloorList.Add(new DetailedFloor
                {
                    Floor = f,
                    GraphBar = new GraphBar()
                });
            }

            return detailedFloorList;
        }

        public static List<DetailedItem> ToDetailedItem(this IEnumerable<Item> items)
        {
            List<DetailedItem> detailedItemList = new List<DetailedItem>(items.Count());

            foreach (Item i in items)
            {
                detailedItemList.Add(new DetailedItem
                {
                    Item = i,
                    GraphBar = new GraphBar()
                });
            }

            return detailedItemList;
        }

        public static List<DetailedItemSource> ToDetailedItemSource(this IEnumerable<ItemSource> itemSources)
        {
            List<DetailedItemSource> detailedItemSources = new List<DetailedItemSource>(itemSources.Count());

            foreach (ItemSource s in itemSources)
            {
                detailedItemSources.Add(new DetailedItemSource
                {
                    ItemSource = s,
                    GraphBar = new GraphBar()
                });
            }

            return detailedItemSources;
        }

        public static List<DetailedTransformation> ToDetailedTransformation(this IEnumerable<Transformation> transformations)
        {
            List<DetailedTransformation> detailedTransformations = new List<DetailedTransformation>(transformations.Count());

            foreach (Transformation t in transformations)
            {
                detailedTransformations.Add(new DetailedTransformation
                {
                    Transformation = t,
                    GraphBar = new GraphBar(),
                    RelevantItemPickups = new List<ItemPickup>()
                });
            }

            return detailedTransformations;
        }

        public static DetailedTransformation ToDetailedTransformation(this Transformation transformation)
        {
            DetailedTransformation detailedTransformation = new DetailedTransformation
            {
                Transformation = transformation,
                GraphBar = new GraphBar(),
                RelevantItemPickups = new List<ItemPickup>()
            };

            return detailedTransformation;
        }
    }
}
