Esempio n. 1
0
        public override int CompareTo(object obj)
        {
            if (obj is GradeWP)
            {
                GradeWP other = obj as GradeWP;

                //oldest grades are shown first
                int compare = Date.Date.CompareTo(other.Date.Date);

                if (compare == 0)
                {
                    //dropped items go after
                    if (IsDropped && !other.IsDropped)
                    {
                        return(1);
                    }

                    //undropped items go before anything dropped
                    if (!IsDropped && other.IsDropped)
                    {
                        return(-1);
                    }

                    //more recently created items appear first if on same day
                    return(DateCreated.CompareTo((obj as GradeWP).DateCreated));
                }

                return(compare);
            }

            return(0);
        }
Esempio n. 2
0
        public int CompareTo(ClassWin other)
        {
            int comp = Name.CompareTo(other.Name);

            if (comp == 0)
            {
                return(DateCreated.CompareTo(other.DateCreated));
            }

            return(comp);
        }
Esempio n. 3
0
        /// <summary>
        /// This is the object's validate method, returns all validation errors in a list that the end user can go through
        /// </summary>
        /// <param name="validationContext"></param>
        /// <returns></returns>
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            IEnumerable <ValidationResult> validationResults = new List <ValidationResult>();
            Validation validator = new Validation();

            var isCommentValid = validator.ValidateString(Comment);

            if (DateCreated.CompareTo(DateTime.Now) > 0)
            {
                validationResults = validationResults.Append(new ValidationResult("Invalid Date. Cannot have a comment created in the future"));
            }
            if (isCommentValid != null)
            {
                validationResults = validationResults.Append(new ValidationResult(isCommentValid));
            }
            if (Rating < 0)
            {
                validationResults = validationResults.Append(new ValidationResult("Rating should be nonnegative"));
            }

            return(validationResults);
        }
Esempio n. 4
0
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <param name="other">
 /// An object to compare with this object.
 /// </param>
 /// <returns>
 /// A 32-bit signed integer that indicates the relative order of the
 ///     objects being compared. The return value has the following meanings:
 ///     Value Meaning Less than zero This object is less than the other parameter.
 ///     Zero This object is equal to other. Greater than zero This object is greater than other.
 /// </returns>
 public int CompareTo(Comment other)
 {
     return(DateCreated.CompareTo(other.DateCreated));
 }
Esempio n. 5
0
 /// <summary>
 /// Things with earlier creation dates go first
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public virtual int CompareTo(BaseDataItem other)
 {
     return(DateCreated.CompareTo(other.DateCreated));
 }