using System;
using Platnosci.Core.Linq;
using System.Web.Mvc;
using Moq;

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

            return platnosc;
        }
        public vPlatnosciEcard CreateForeignInvoice(int id, string nip, string invoiceNumber, decimal brutto, byte systemKsiegowy, decimal walutaBrutto, string currency)
        {
            var platnosc = new vPlatnosciEcard();
            platnosc.ID_faktury = id;
            platnosc.nip = nip;
            platnosc.Faktura_Numer = invoiceNumber;
            platnosc.Brutto = brutto;
            platnosc.waluta_brutto = walutaBrutto;
            platnosc.waluta_miano = currency;
            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;
        }
    }
}
