示例#1
0
        public Megusta AddMegusta(Megusta megusta)
        {
            using (var ctx = new ContextoIndignadoFramework())
            {
                ctx.MegustaSet.AddObject(megusta);
                ctx.SaveChanges();
            }

            return(megusta);
        }
示例#2
0
 public void UpdateMegusta(Megusta megusta)
 {
     if (megusta == null)
     {
         throw new ArgumentNullException(ENTITY_SET_NAME);
     }
     using (var ctx = new ContextoIndignadoFramework())
     {
         var    key      = ctx.CreateEntityKey(ENTITY_SET_NAME, megusta);
         object original = null;
         if (ctx.TryGetObjectByKey(key, out original))
         {
             ctx.ApplyCurrentValues(key.EntitySetName, megusta);
         }
         ctx.SaveChanges();
     }
 }
示例#3
0
        public void AddMeGusta(int idUsr, int idContenido)
        {
            Megusta megusta = new Megusta {
                ContenidoId = idContenido, Fecha = DateTime.Now, EspecificacionUsuarioId = idUsr
            };
            Contenido cont = null;

            using (var ts = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    mgdac.AddMegusta(megusta);
                    cont = cdac.SelectById(idContenido);
                    cont.CantMeGusta++;
                    cdac.UpdateContenido(cont);
                    ts.Complete();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }