using System;
using Baza_Reklam.Classes.Model;

namespace Baza_Reklam.Classes.Helpers
{
    public struct AdSize
    {
        public decimal Width;
        public decimal Height;
    }

    public class AdHelper
    {
        //TODO: get the initial ad size, margin size and max width height from db
        public static AdSize GetAdSize(int horizontal, int vertical, Module module)
        {
            AdSize adSize = new AdSize();

            if (!module.MultiModule)
            {
                adSize.Width = Convert.ToInt32(module.Width);
                adSize.Height = Convert.ToInt32(module.Height);
                return adSize;
            }

            decimal width = ((horizontal - 1) * module.MarginHorizontal) + (horizontal * module.Width.Value);
            decimal height = Convert.ToInt32(((vertical - 1) * module.MarginVertical) + (vertical * module.Height));
            
            adSize.Width = width;
            adSize.Height = height;
            return adSize;
        }
    }
}