public Megusta AddMegusta(Megusta megusta) { using (var ctx = new ContextoIndignadoFramework()) { ctx.MegustaSet.AddObject(megusta); ctx.SaveChanges(); } return(megusta); }
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(); } }
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); } } }