Esempio n. 1
0
        public static Feed Insert(Feed oFeed)
        {
            int QtRes = -1;

            // Ajuste dos campos


            using (var context = new bancoRSSEntities())
            {
                Feed resFeed = context.Feeds
                               .Where(b => b.feed_url.Equals(oFeed.feed_url))
                               .FirstOrDefault();

                if (resFeed == null)
                {
                    try
                    {
                        context.Feeds.Add(oFeed);
                        QtRes = context.SaveChanges();
                    }
                    catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                    {
                    }
                }
            }

            return(oFeed);
        }
Esempio n. 2
0
        public static Item Insert(Item oItem)
        {
            int QtRes = -1;

            // Ajuste dos campos
            if (oItem.item_dthr < DateTime.Now.AddYears(-1))
            {
                oItem.item_dthr = DateTime.Now;
            }

            while (oItem.item_titulo.Contains("  "))
            {
                oItem.item_titulo = oItem.item_titulo.Replace("  ", " ");
            }

            using (var context = new bancoRSSEntities())
            {
                Item resItem = context.Items
                               .Where(b => b.item_url.Equals(oItem))
                               .FirstOrDefault();

                if (resItem == null)
                {
                    try
                    {
                        context.Items.Add(oItem);
                        QtRes = context.SaveChanges();
                    }
                    catch (System.Data.Entity.Validation.DbEntityValidationException ex)
                    {
                    }
                }
            }

            return(oItem);
        }