Ejemplo n.º 1
0
        private bool _SetUnitDocumentState(Guid id, Guid docId, Guid?mDocId, MemberUnitDocumentActions allowedActions, Model.DocumentStatus targetState, bool fromUser)
        {
            MemberUnitDocument doc = null;

            Model.MemberUnitDocument modelDoc = null;
            if (mDocId.HasValue)
            {
                modelDoc = db.MemberUnitDocuments.Include("Document.Unit", "Member").Single(f => f.Id == mDocId);
                doc      = MemberUnitDocument.MemberUnitDocumentConversion.Compile()(modelDoc);
            }
            else
            {
                var unitDoc = db.UnitDocuments.Include("Unit").Single(f => f.Id == docId);
                var member  = db.Members.Single(f => f.Id == id);
                modelDoc = new Model.MemberUnitDocument
                {
                    Member   = member,
                    Document = unitDoc,
                    Status   = Model.DocumentStatus.NotStarted,
                };
                member.UnitDocuments.Add(modelDoc);
                doc = db.UnitDocuments.Where(f => f.Id == docId).Select(MemberUnitDocument.UnitDocumentConversion).Single();
            }

            FilterUnitDocActions(id, doc);

            if ((doc.Actions & allowedActions) == MemberUnitDocumentActions.None)
            {
                ThrowAuthError();
            }

            modelDoc.Status = targetState;
            if (fromUser)
            {
                modelDoc.UnitAction = DateTime.Now;
            }
            else
            {
                modelDoc.MemberAction = DateTime.Now;
            }

            db.SaveChanges();

            return(true);
        }
Ejemplo n.º 2
0
        private MemberUnitDocument FilterUnitDocActions(Guid memberId, MemberUnitDocument doc)
        {
            var self = this.Permissions.IsSelf(memberId);

            if (!self)
            {
                doc.Actions = doc.Actions & ~MemberUnitDocumentActions.UserReview;
            }
            if (!this.Permissions.IsAdmin)
            {
                if (!this.Permissions.IsRoleForUnit("applicants", doc.Unit.Id) && !this.Permissions.IsMembershipForUnit(doc.Unit.Id))
                {
                    // If not management, remove the unit-level links
                    doc.Actions = doc.Actions & ~(MemberUnitDocumentActions.Complete | MemberUnitDocumentActions.Reject);

                    // If not management and not editing yourself, remove the 'submit' action.
                    if (!self)
                    {
                        doc.Actions = doc.Actions & ~MemberUnitDocumentActions.Submit;
                    }
                }
            }
            return(doc);
        }
Ejemplo n.º 3
0
        private MemberUnitDocument FilterUnitDocActions(Guid memberId, MemberUnitDocument doc)
        {
            var self = this.Permissions.IsSelf(memberId);
              if (!self) doc.Actions = doc.Actions & ~MemberUnitDocumentActions.UserReview;
              if (!this.Permissions.IsAdmin)
              {
            if (!this.Permissions.IsRoleForUnit("applicants", doc.Unit.Id) && !this.Permissions.IsMembershipForUnit(doc.Unit.Id))
            {
              // If not management, remove the unit-level links
              doc.Actions = doc.Actions & ~(MemberUnitDocumentActions.Complete | MemberUnitDocumentActions.Reject);

              // If not management and not editing yourself, remove the 'submit' action.
              if (!self) doc.Actions = doc.Actions & ~MemberUnitDocumentActions.Submit;
            }
              }
              return doc;
        }