﻿using System;
using System.Collections.Generic;
using System.Linq;
using IBSAT.Data;
using IBSAT.Models;

namespace IBSAT.Business
{
    public class AvisoBusiness: CoreBusiness
    {
        #region Construtor
        public AvisoBusiness()
        {
            ObjAviso = new AvisoData();
        }
        #endregion

        #region

        public AvisoData ObjAviso { get; set; }
        
        #endregion


        /// <summary>
        /// Recuperar o primeiro vídeo do dia
        /// </summary>
        /// <returns></returns>
        public AvisoModels ObterAviso()
        {
            List<AvisoModels> lobjAviso = ObjAviso.ObterLista();

            if (lobjAviso.Count == 0)
                return null;

            return lobjAviso.FirstOrDefault(x => x.DATA_INICIO < DateTime.Now && x.DATA_FINAL > DateTime.Now);
        }
    }
}
