private ActionResult ChangeState(int id, TopicAction state, string view)
        {
            ActiveSession session = GetSession();
            if (session == null)
                return HTTPStatus(HttpStatusCode.Forbidden, "Keine Sitzung gefunden.");

            TopicLock tlock = db.TopicLocks
                .Include(tl => tl.Session)
                .Include(tl => tl.Topic)
                .Single(tl => tl.TopicID == id);

            if (tlock.Session.ID != session.ID)
                return HTTPStatus(HttpStatusCode.Forbidden, "Falsche Sitzung.");

            // Den Beschluss verhindern, falls noch offene Aufgaben vorliegen
            if (state == TopicAction.Decide &&
                tlock.Topic.Assignments.Any(a => a.Type == AssignmentType.ToDo && !a.IsDone && a.IsActive))
            {
                tlock.Message = "Es liegen noch offene ToDo-Aufgaben vor. Dieses Thema kann daher nicht beschlossen werden.";
                return PartialView(view, tlock);
            }

            // Den Beschluss verhindern, falls der Punkt verschoben wird
            if (state != TopicAction.None && tlock.Topic.TargetSessionTypeID != null)
            {
                tlock.Message = "Der Punkt ist zum Verschieben vorgemerkt und darf daher nicht behandelt werden.";
                return PartialView(view, tlock);
            }

            tlock.Action = state;

            try
            {
                db.SaveChanges();
            }
            catch (DbEntityValidationException e)
            {
                string message = ErrorMessageFromException(e);
                return HTTPStatus(HttpStatusCode.InternalServerError, message);
            }

            return PartialView(view, tlock);
        }
Esempio n. 2
0
 /// <summary>
 /// Acl the specified action.
 /// </summary>
 /// <remarks></remarks>
 /// <param name="action">Action.</param>
 /// <returns>ACL of this KiiTopic.</returns>
 public KiiTopicACL Acl(TopicAction action)
 {
     return(new KiiTopicACL(this, action));
 }
        public ActionResult _ChangeState(int id, TopicAction state, string view)
        {
            var appropriateView = view == "Table" ? "_StateDropdown" : "_StateButtons";

            return ChangeState(id, state, appropriateView);
        }