Ejemplo n.º 1
0
        void LoadNestedMessage(Message msg)
        {
            if (msg.Messages == null)
            {
                db.Entry(msg).Collection(m => m.Messages).Load();
            }

            if (msg.Writer == null)
            {
                db.Entry(msg).Reference(m => m.Writer).Load();
            }

            foreach (var subMsg in msg.Messages)
            {
                LoadNestedMessage(subMsg);
            }
        }
Ejemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "Year,Number,Active")] Issue issue)
 {
     if (ModelState.IsValid)
     {
         db.Entry(issue).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(issue));
 }
Ejemplo n.º 3
0
        // <asp:FormView ID="issueView" UpdateMethod="UpdateIssue" />
        public void UpdateIssue(int id, byte[] timestamp, [CurrentUser] string currentUser, [Control("ctl00$MainContent$issueForm$forceSave")] bool?forceSave)
        {
            if (String.IsNullOrEmpty(currentUser))
            {
                ModelState.AddModelError("", "You must be signed in to update issues");
                return;
            }

            var issue = _db.Issues.Find(id);

            TryUpdateModel(issue);
            if (forceSave.HasValue && !forceSave.Value)
            {
                // Set original timestamp value so EF can detect optimistic concurrency violation
                _db.Entry(issue).Property(i => i.Timestamp).OriginalValue = timestamp;
            }

            if (ModelState.IsValid)
            {
                SaveChanges(issue);
            }
        }