/// <summary> /// Retrieve the current week. /// </summary> /// <param name="userId">Id of the user.</param> /// <returns></returns> public static Weeks GetWeek(ObjectId userId) { Weeks week = MongoManager.GetAggregate <Weeks>(weeksIndex, x => x.UserId == userId).FirstOrDefault(); if (week == null) { week = new Weeks(); week.Days = new List <Day>(); return(week); } week.Days = week.Days.OrderBy(x => x.Position).ToList(); return(week); }
/// <summary> /// Override of the equality method. /// </summary> /// <param name="o"></param> /// <returns></returns> public bool Equals(Weeks o) { //Check whether the compared object is null. if (ReferenceEquals(o, null)) { return(false); } //Check whether the compared object references the same data. if (ReferenceEquals(this, o)) { return(true); } //Check whether the Weeks' properties are equal. return(_id.Equals(o._id) && UserId.Equals(o.UserId) && StartTime.Equals(o.StartTime) && Tools.SequenceEqual(Days, o.Days)); }