Ejemplo n.º 1
0
        public int AddEntry(SourceEntryObj e, string username)
        {
            using (var db = GetNewsFeedEntities())
            {
                var dbEntry = new NewsFeedEntry
                {
                    Title = e.Title,
                    Message = e.Message,
                    CreatedOn = DateTime.Now,
                    CreatedBy = username
                };

                db.NewsFeedEntries.AddObject(dbEntry);

                db.SaveChanges();

                return dbEntry.Id;
            }
        }
Ejemplo n.º 2
0
        public bool UpdateEntry(SourceEntryObj e, string username)
        {
            using (var db = GetNewsFeedEntities())
            {
                var dbEntry = db.NewsFeedEntries.SingleOrDefault(nfe => nfe.Id == e.Id);
                if (dbEntry == null)
                {
                    return false;
                }

                dbEntry.Title = e.Title;
                dbEntry.Message = e.Message;
                dbEntry.UpdatedOn = DateTime.Now;
                dbEntry.UpdatedBy = username;

                db.SaveChanges();

                return true;
            }
        }