using System;
using adMoto.Payments.Core;
using adMoto.Payments.Core.Data;
using System.Web.Mvc;
using Moq;

namespace adMoto.Payments.Test.Web
{
    public class Function
    {
        public Invoice CreateInvoice(int id, string nip, string invoiceNumber, decimal brutto, byte systemKsiegowy)
        {
            var platnosc = new Invoice();
            platnosc.ID_faktury = id;
            platnosc.nip = nip;
            platnosc.Faktura_Numer = invoiceNumber;
            platnosc.Brutto = brutto;
            platnosc.SystemKsiegowyId = systemKsiegowy;

            return platnosc;
        }
        public Invoice CreateForeignInvoice(int id, string nip, string invoiceNumber, decimal brutto, byte systemKsiegowy, decimal walutaBrutto, string currency)
        {
            var platnosc = new Invoice();
            platnosc.ID_faktury = id;
            platnosc.nip = nip;
            platnosc.Faktura_Numer = invoiceNumber;
            platnosc.Brutto = brutto;
            platnosc.waluta_brutto = walutaBrutto;
            platnosc.waluta_miano = currency.ToUpper();
            platnosc.SystemKsiegowyId = systemKsiegowy;
           
            return platnosc;
        }
        public PlatnosciEcard CreateNewPayment(int orderNumber, bool status, DateTime data, int invoiceId)
        {
            var platnosc = new PlatnosciEcard();
            platnosc.ORDERNUMBER = orderNumber;
            platnosc.Status = status;
            platnosc.Status_data = data;
            platnosc.IDFaktury = invoiceId;

            return platnosc;
        }
        public PotwierdzeniaEcard CreateConfirm(string code, int ordernumber)
        {
            var potwierdzenie = new PotwierdzeniaEcard();
            potwierdzenie.CURRENTSTATE = code;
            potwierdzenie.ORDERNUMBER = ordernumber;

            return potwierdzenie;
        }
        
        public Payer CreatePayer(int id, string name, string surname)
        {
            var payer = new Payer {Id_faktury = id, FirstName = name, LastName = surname};

            return payer;
        }

        public ControllerContext CreateControllerContext(string userIdentity)
        {

            var mock = new Mock<ControllerContext>();
            mock.SetupGet(m => m.HttpContext.User.Identity.Name).Returns(userIdentity);
            mock.SetupGet(m => m.HttpContext.Request.IsAuthenticated).Returns(true);
           
            return mock.Object;
        }
    }
}
