public override void Run(RuleContext context)
 {
     context.Message = ErrorMessage;
     context.Success = true;
     // Only set if CanRun and if the value has not been manually changed.
     if (CanRun(context.TrackedObject) && !IsPropertyValueModified(context.TrackedObject.Original, context.TrackedObject.Current))
         SetPropertyValue(context.TrackedObject.Current, GetCurrentUserNameUserId());
 }
        public void Run(RuleContext context)
        {
            var currentUser = (User)context.TrackedObject.Current;

            using (var db = new TrackerDataContext())
            {
                db.ObjectTrackingEnabled = false;
                var user = db.User.GetByEmailAddress(currentUser.EmailAddress);
                context.Success = (null == user || user.Id == currentUser.Id);
            }
        }
        public void Run(RuleContext context)
        {
            context.Message = ErrorMessage;

            DateTime? startDate = ((Task) context.TrackedObject.Current).StartDate;
            DateTime? dueDate = ((Task) context.TrackedObject.Current).DueDate;

            if ((null == startDate) || (null == dueDate))
                context.Success = true;
            else
                context.Success = (dueDate >= startDate);
        }
        public void Run(RuleContext context)
        {
            context.Success = true;

            if (HttpContext.Current != null)
            {
                var task = (Task) context.TrackedObject.Current;

                using (var db = new TrackerDataContext())
                {
                    var options = new DataLoadOptions();
                    options.LoadWith<UserRole>(r => r.Role);
                    db.LoadOptions = options;

                    User currentUser = db.User.GetByEmailAddress(HttpContext.Current.User.Identity.Name);
                    context.Success = (null == db.UserRole.GetUserRole("Newb", currentUser.Id));
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BrokenRule"/> class.
 /// </summary>
 /// <param name="context">The rule context.</param>
 internal BrokenRule(RuleContext context)
 {
     Message = context.Message;
     Context = context;
 }
 /// <summary>
 /// Runs the specified rule using the <see cref="RuleContext"/>.
 /// </summary>
 /// <param name="context">The current <see cref="RuleContext"/>.</param>
 public abstract void Run(RuleContext context);