Carrotware.CMS.Core.EditHistory.GetHistoryListCount C# (CSharp) Method

GetHistoryListCount() public static method

public static GetHistoryListCount ( System.Guid siteID, bool showLatestOnly, System.DateTime editDate, System.Guid editUserID ) : int
siteID System.Guid
showLatestOnly bool
editDate System.DateTime
editUserID System.Guid
return int
        public static int GetHistoryListCount(Guid siteID, bool showLatestOnly, DateTime? editDate, Guid? editUserID)
        {
            Guid userID = Guid.Empty;
            if (editUserID.HasValue) {
                userID = editUserID.Value;
            }

            DateTime dateStart = DateTime.UtcNow.Date.AddDays(-2);
            DateTime dateEnd = DateTime.UtcNow.Date.AddDays(1);

            if (editDate.HasValue) {
                dateStart = editDate.Value.Date.AddDays(-8);
                dateEnd = editDate.Value.Date.AddDays(1);
            }

            using (CarrotCMSDataContext _db = CarrotCMSDataContext.Create()) {
                return (from h in _db.vw_carrot_EditHistories
                        where h.SiteID == siteID
                            && (!showLatestOnly || h.IsLatestVersion == true)
                            && (!editDate.HasValue
                                  || (h.EditDate.Date >= dateStart.Date && h.EditDate.Date <= dateEnd.Date))
                            && (!editUserID.HasValue || h.EditUserId == userID)
                        select h).Count();
            }
        }