using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuintoCaminoV2.Data_objects;

namespace QuintoCaminoV2.Users
{
    public partial class ClasesUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int IdCurso = Convert.ToInt32(Request.QueryString["iCursoId"]);
            getClases(IdCurso);
            //player("INTRO_PAG_NEGRO.mp4");
        }

        public void player(string NameVideo)
        {
            try
            {

                string path ="\\uploads\\Clases\\" + NameVideo;
                sampleMovie.Attributes.Add("src", path);
                sampleMovie.DataBind();

            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }

        public void getClases(int idCurso)
        {
            

            DataLayer oDataLayer = new DataLayer();
            Data_objects.Clases oClases = new Data_objects.Clases();
            oClases.intCursoId = idCurso;
            DateTime fPrincipioMes;

            int var_mesActual = DateTime.Now.Month;             // obtengo el mes actual
            int var_anio = DateTime.Now.Year;                   // obtengo el año actual            
            fPrincipioMes = Convert.ToDateTime("01/" + var_mesActual + "/" + var_anio);

            List<Data_objects.Clases> lstClases = new List<Data_objects.Clases>();
            lstClases = oDataLayer.get_Clases(oClases);

            var oData = from d in lstClases
                        where Convert.ToDateTime(d.datFalta) > fPrincipioMes
                        select d;

            foreach (Data_objects.Clases oCla in oData)
            {
                lblTitulo.Text = oCla.vchTituloClase;
                lblDescripCorta.Text = oCla.vchDescClase;
                lblFecha.Text = oCla.datFalta;
            }



            var oData2 = from d in lstClases                         
                         select d;

            //where Convert.ToDateTime(d.datFalta) < fPrincipioMes

            DataClases.DataSource = oData2;
            DataClases.DataBind();
        }

        protected void DataClases_ItemCommand(object source, DataListCommandEventArgs e)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(@"<script type='text/javascript'>");
            sb.Append("$('#modalSignUp2').modal('show');");
            sb.Append(@"</script>");
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ModalScript", sb.ToString(), false);
        }
    }
}