Ejemplo n.º 1
0
        public int UpdateNewsFeed(NewsFeed i)
        {
            int val   = 0;
            int newID = 0;

            try
            {
                using (ClusmextContext context = new ClusmextContext())
                {
                    if (i.IdItem > 0)
                    {
                        context.Entry(i).State = EntityState.Modified;
                    }
                    else
                    {
                        context.Entry(i).State = EntityState.Added;
                    }

                    val   = context.SaveChanges();
                    newID = i.IdItem;
                }
            }
            catch (Exception ex)
            {
            }

            return(newID);
        }
Ejemplo n.º 2
0
        public NewsFeed GetNewById(int id = 0)
        {
            NewsFeed s = new NewsFeed();

            if (id == 0)
            {
                s.IdItem = -1;
                //s.Descripcion = "Empty";
                return(s);
            }

            try
            {
                using (ClusmextContext context = new ClusmextContext())
                {
                    s = context.NewsFeed.Where(x => x.IdItem == id).SingleOrDefault();
                }
            }
            catch (Exception ex)
            {
            }
            return(s);
        }