Esempio n. 1
0
 public static SimplifiedMessage GetMessage(int id)
 {
     using (var context = new versioningEntities())
     {
         var result = context.SimplifiedMessages.Single(m => m.Id == id);
         return result;
     }
 }
Esempio n. 2
0
        public static void UpdateMessage(SimplifiedMessage message)
        {
            using (var context = new versioningEntities())
            {
                context.SimplifiedMessages.Attach(message);
                context.Entry(message).State = EntityState.Modified;

                try
                {
                    context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException updateConcurrencyException)
                {
                    var ex = new ConcurrencyException("Update failed.", updateConcurrencyException);
                    throw ex;
                }
            }
        }
Esempio n. 3
0
        public ActionResult Index()
        {
            using (var context = new versioningEntities())
            {
                var messages = context.SimplifiedMessages.ToList();
                var query = from m in messages
                            select new SimplifiedMessageEncrypted
                                    {
                                        Id = m.Id,
                                        Number = m.Number,
                                        Created = m.Created,
                                        Version = m.Version,
                                        Modified = m.Modified,
                                        EncryptedVersion = this.Encrypt(m.Version)
                                    };

                return this.View(query.ToList());
            }
        }