public OpcionesContenido GetOpcionesContenido(int idUsr, int id)
        {
            OpcionesContenido ocont = new OpcionesContenido();

            ocont.Inadecuado = true;
            ocont.MeGusta    = true;
            Contenido cont;

            using (var ctx = new ContextoIndignadoFramework())
            {
                cont = ctx.ContenidoSet.Include("Megusta").Include("Inadecuados").Where(c => c.Id == id).FirstOrDefault();
                ocont.CantMeGusta = cont.Megusta.Count;
                foreach (EspecificacionUsuario eu in cont.Inadecuados)
                {
                    if (eu.Id == idUsr)
                    {
                        ocont.Inadecuado = false;
                    }
                }
                foreach (Megusta mg in cont.Megusta)
                {
                    if (mg.EspecificacionUsuarioId == idUsr)
                    {
                        ocont.MeGusta = false;
                    }
                }
            }
            return(ocont);
        }
예제 #2
0
        public OpcionesContenido GetOpcionesContenido(int idUsr, int idContenido)
        {
            OpcionesContenido ocont = null;

            using (var ts = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    ocont = cdac.GetOpcionesContenido(idUsr, idContenido);
                    ts.Complete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(ocont);
        }