public static int LoadUnreadMessageCount(LoginUser loginUser, User user, int lastMessageID) { WaterCooler waterCooler = new WaterCooler(loginUser); using (SqlCommand command = new SqlCommand()) { command.CommandText = @" SELECT COUNT(*) FROM WaterCooler WHERE OrganizationID = @OrganizationID AND UserID <> @UserID AND MessageID > @MessageID AND (ISNULL(GroupFor,0) = 0 OR (ISNULL(GroupFor,0) IN (SELECT GroupID FROM GroupUsers WHERE UserID = @UserID)))"; command.CommandType = CommandType.Text; command.Parameters.AddWithValue("@OrganizationID", user.OrganizationID); command.Parameters.AddWithValue("@UserID", user.UserID); command.Parameters.AddWithValue("@MessageID", lastMessageID); object o = waterCooler.ExecuteScalar(command); if (o == null || o == DBNull.Value) { return(0); } return((int)o); } }
public static int GetLastMessageID(LoginUser loginUser) { WaterCooler cooler = new WaterCooler(loginUser); cooler.LoadLastMessageID(loginUser.OrganizationID, loginUser.UserID); if (cooler.IsEmpty) { return(-1); } return(cooler[0].MessageID); }
public static WaterCoolerItem GetWaterCoolerItem(LoginUser loginUser, int messageID) { WaterCooler waterCooler = new WaterCooler(loginUser); waterCooler.LoadByMessageID(messageID); if (waterCooler.IsEmpty) { return(null); } else { return(waterCooler[0]); } }
public WaterCoolerItem(DataRow row, WaterCooler waterCooler) : base(row, waterCooler) { _waterCooler = waterCooler; }