Beispiel #1
0
        public ActionResult PostMessageModified(int messageId, string version)
        {
            var versionEncryptedBytes = MachineKeySectionWrapper.HexStringToByteArray(version);
            var versionBytes = MachineKeySectionWrapper.Decrypt(versionEncryptedBytes);

            var yesterday = DateTime.Now.AddDays(-1);

            var message = new SimplifiedMessage
                {
                    Id = messageId,
                    Version = versionBytes,
                    Created = yesterday,
                    Modified = yesterday,
                    Number = yesterday.Millisecond.ToString()
                };

            try
            {
                MessageRepository.UpdateMessage(message);
            }
            catch (ConcurrencyException)
            {
                return new HttpStatusCodeResult((int)HttpStatusCode.InternalServerError, "Concurrency error");
            }

            return this.Json(message, JsonRequestBehavior.AllowGet);
        }
Beispiel #2
0
        public static string GetVersionString(this SimplifiedMessage message, byte[] version)
        {
            string versionStr = "";

            foreach (var by in version)
            {
                string byteDisplay = string.Format("[{0}] ", by);
                versionStr += byteDisplay;
            }

            return(versionStr);
        }
Beispiel #3
0
 public SimplifiedMessage UpdateMessage(SimplifiedMessage message)
 {
     try
     {
         MessageRepository.UpdateMessage(message);
         return message;
     }
     catch (ConcurrencyException)
     {
         var ex = new FaultException<ConcurrencyFault>(
             new ConcurrencyFault(), "Concurrency exception.");
         throw ex;
     }
 }
Beispiel #4
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;
                }
            }
        }